From 658006e7eedfd6a09fa7ee439e5fee1dbc81752b Mon Sep 17 00:00:00 2001 From: incrementby1 Date: Thu, 28 Oct 2021 23:29:26 +0200 Subject: [PATCH] removed wrong use of map and filter function --- freqtrade/persistence/pairlock_middleware.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/freqtrade/persistence/pairlock_middleware.py b/freqtrade/persistence/pairlock_middleware.py index 386c3d1d7..f1ed50ec7 100644 --- a/freqtrade/persistence/pairlock_middleware.py +++ b/freqtrade/persistence/pairlock_middleware.py @@ -114,9 +114,6 @@ class PairLocks(): if not now: now = datetime.now(timezone.utc) - def local_unlock(lock): - lock.active = False - if PairLocks.use_db: # used in live modes logger.info(f"Releasing all locks with reason \'{reason}\':") @@ -126,13 +123,15 @@ class PairLocks(): ] locks = PairLock.query.filter(*filters) for lock in locks: - logger.info(f"Releasing lock for \'{lock.pair}\' with reason \'{reason}\'.") + logger.info(f"Releasing lock for {lock.pair} with reason \'{reason}\'.") lock.active = False PairLock.query.session.commit() else: - # no logging in backtesting to increase speed - locks = filter(lambda reason: reason == reason, PairLocks.locks) - locks = map(local_unlock, locks) + # used in backtesting mode; don't show log messages for speed + locks = PairLocks.get_locks(None) + for lock in locks: + if lock.reason == reason: + lock.active = False @staticmethod def is_global_lock(now: Optional[datetime] = None) -> bool: @@ -159,7 +158,9 @@ class PairLocks(): @staticmethod def get_all_locks() -> List[PairLock]: - + """ + Return all locks, also locks with expired end date + """ if PairLocks.use_db: return PairLock.query.all() else: