Begin work on scheduling management command

This commit is contained in:
2023-02-17 07:20:19 +00:00
parent ffdbcecc8d
commit da67177a18
9 changed files with 126 additions and 1 deletions

19
core/trading/checks.py Normal file
View File

@@ -0,0 +1,19 @@
from datetime import datetime
from core.util import logs
log = logs.get_logger("checks")
def within_trading_times(strategy, ts=None):
if not ts:
ts = datetime.utcnow()
# Check if we can trade now!
trading_times = strategy.trading_times.all()
if not trading_times:
log.error("No trading times set for strategy")
return False
matches = [x.within_range(ts) for x in trading_times]
if not any(matches):
log.debug("Not within trading time range")
return False
return True