Apply all stops in the list, even if the first would apply already

This commit is contained in:
Matthias 2020-11-15 11:41:48 +01:00
parent 9484ee6690
commit 5133675988

View File

@ -48,21 +48,22 @@ class ProtectionManager():
def global_stop(self) -> bool: def global_stop(self) -> bool:
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
result = False
for protection_handler in self._protection_handlers: for protection_handler in self._protection_handlers:
result, until, reason = protection_handler.global_stop(now) result, until, reason = protection_handler.global_stop(now)
# Early stopping - first positive result blocks further trades # Early stopping - first positive result blocks further trades
if result and until: if result and until:
PairLocks.lock_pair('*', until, reason) PairLocks.lock_pair('*', until, reason)
return True result = True
return False return result
def stop_per_pair(self, pair) -> bool: def stop_per_pair(self, pair) -> bool:
now = datetime.now(timezone.utc) now = datetime.now(timezone.utc)
result = False
for protection_handler in self._protection_handlers: for protection_handler in self._protection_handlers:
result, until, reason = protection_handler.stop_per_pair(pair, now) result, until, reason = protection_handler.stop_per_pair(pair, now)
if result and until: if result and until:
PairLocks.lock_pair(pair, until, reason) PairLocks.lock_pair(pair, until, reason)
return True result = True
return False return result