Begin work on scheduling management command
This commit is contained in:
19
core/trading/checks.py
Normal file
19
core/trading/checks.py
Normal 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
|
||||
Reference in New Issue
Block a user