Add "allow_position_stacking" value to config, which allows rebuys of a pair

Add function unlock_reason(str: pair) which removes all PairLocks with reason
Provide demo strategy that allows buying the same pair multiple times
This commit is contained in:
incrementby1
2021-10-26 00:04:40 +02:00
parent b4bedc22d7
commit c3f3bdaa2a
6 changed files with 727 additions and 5 deletions

View File

@@ -103,6 +103,24 @@ class PairLocks():
if PairLocks.use_db:
PairLock.query.session.commit()
@staticmethod
def unlock_reason(reason: str, now: Optional[datetime] = None) -> None:
"""
Release all locks for this reason.
:param reason: Which reason to unlock
:param now: Datetime object (generated via datetime.now(timezone.utc)).
defaults to datetime.now(timezone.utc)
"""
if not now:
now = datetime.now(timezone.utc)
logger.info(f"Releasing all locks with reason \'{reason}\'.")
locks = PairLocks.get_all_locks()
for lock in locks:
if lock.reason == reason:
lock.active = False
if PairLocks.use_db:
PairLock.query.session.commit()
@staticmethod
def is_global_lock(now: Optional[datetime] = None) -> bool:
"""