implement pairlock side further

This commit is contained in:
Matthias
2022-04-24 11:23:26 +02:00
parent 420836b1b2
commit fc201bb4ff
6 changed files with 28 additions and 16 deletions

View File

@@ -54,8 +54,9 @@ class ProtectionManager():
if protection_handler.has_global_stop:
lock = protection_handler.global_stop(date_now=now, side=side)
if lock and lock.until:
if not PairLocks.is_global_lock(lock.until):
result = PairLocks.lock_pair('*', lock.until, lock.reason, now=now)
if not PairLocks.is_global_lock(lock.until, lock.lock_side):
result = PairLocks.lock_pair(
'*', lock.until, lock.reason, now=now, side=lock.lock_side)
return result
def stop_per_pair(self, pair, now: Optional[datetime] = None,
@@ -68,6 +69,7 @@ class ProtectionManager():
lock = protection_handler.stop_per_pair(
pair=pair, date_now=now, side=side)
if lock and lock.until:
if not PairLocks.is_pair_locked(pair, lock.until):
result = PairLocks.lock_pair(pair, lock.until, lock.reason, now=now)
if not PairLocks.is_pair_locked(pair, lock.until, lock.lock_side):
result = PairLocks.lock_pair(
pair, lock.until, lock.reason, now=now, side=lock.lock_side)
return result

View File

@@ -20,7 +20,7 @@ class ProtectionReturn:
lock: bool
until: datetime
reason: Optional[str]
lock_side: Optional[str] = None
lock_side: str = '*'
class IProtection(LoggingMixin, ABC):

View File

@@ -65,7 +65,7 @@ class StoplossGuard(IProtection):
lock=True,
until=until,
reason=self._reason(),
lock_side=(side if self._only_per_side else None)
lock_side=(side if self._only_per_side else '*')
)
def global_stop(self, date_now: datetime, side: LongShort) -> Optional[ProtectionReturn]: