Пример #1
0
 def unlock_reason(self, reason: str) -> None:
     """
     Unlocks all pairs previously locked using lock_pair with specified reason.
     Not used by freqtrade itself, but intended to be used if users lock pairs
     manually from within the strategy, to allow an easy way to unlock pairs.
     :param reason: Unlock pairs to allow trading again
     """
     PairLocks.unlock_reason(reason, datetime.now(timezone.utc))
Пример #2
0
def test_PairLocks_reason(use_db):
    PairLocks.timeframe = '5m'
    PairLocks.use_db = use_db
    # No lock should be present
    if use_db:
        assert len(PairLock.query.all()) == 0

    assert PairLocks.use_db == use_db

    PairLocks.lock_pair('XRP/USDT',
                        arrow.utcnow().shift(minutes=4).datetime, 'TestLock1')
    PairLocks.lock_pair('ETH/USDT',
                        arrow.utcnow().shift(minutes=4).datetime, 'TestLock2')

    assert PairLocks.is_pair_locked('XRP/USDT')
    assert PairLocks.is_pair_locked('ETH/USDT')

    PairLocks.unlock_reason('TestLock1')
    assert not PairLocks.is_pair_locked('XRP/USDT')
    assert PairLocks.is_pair_locked('ETH/USDT')

    PairLocks.reset_locks()
    PairLocks.use_db = True