removed wrong use of map and filter function
This commit is contained in:
parent
02e69e1667
commit
658006e7ee
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user