You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
537 B
Python

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