Add "now" to lock_pair method
This commit is contained in:
parent
59091ef2b7
commit
fc97266dd4
@ -22,10 +22,19 @@ class PairLocks():
|
|||||||
timeframe: str = ''
|
timeframe: str = ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def lock_pair(pair: str, until: datetime, reason: str = None) -> None:
|
def lock_pair(pair: str, until: datetime, reason: str = None, *, now: datetime = None) -> None:
|
||||||
|
"""
|
||||||
|
Create PairLock from now to "until".
|
||||||
|
Uses database by default, unless PairLocks.use_db is set to False,
|
||||||
|
in which case a list is maintained.
|
||||||
|
:param pair: pair to lock. use '*' to lock all pairs
|
||||||
|
:param until: End time of the lock. Will be rounded up to the next candle.
|
||||||
|
:param reason: Reason string that will be shown as reason for the lock
|
||||||
|
:param now: Current timestamp. Used to determine lock start time.
|
||||||
|
"""
|
||||||
lock = PairLock(
|
lock = PairLock(
|
||||||
pair=pair,
|
pair=pair,
|
||||||
lock_time=datetime.now(timezone.utc),
|
lock_time=now or datetime.now(timezone.utc),
|
||||||
lock_end_time=timeframe_to_next_date(PairLocks.timeframe, until),
|
lock_end_time=timeframe_to_next_date(PairLocks.timeframe, until),
|
||||||
reason=reason,
|
reason=reason,
|
||||||
active=True
|
active=True
|
||||||
|
@ -55,7 +55,7 @@ class ProtectionManager():
|
|||||||
# Early stopping - first positive result blocks further trades
|
# Early stopping - first positive result blocks further trades
|
||||||
if result and until:
|
if result and until:
|
||||||
if not PairLocks.is_global_lock(until):
|
if not PairLocks.is_global_lock(until):
|
||||||
PairLocks.lock_pair('*', until, reason)
|
PairLocks.lock_pair('*', until, reason, now=now)
|
||||||
result = True
|
result = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user