implement pairlock side further
This commit is contained in:
@@ -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
|
||||
|
@@ -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):
|
||||
|
@@ -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]:
|
||||
|
Reference in New Issue
Block a user