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

View File

@@ -0,0 +1,3 @@
class ActiveManagement(object):
def __init__(self, strategy):
self.strategy = strategy

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

View File

@@ -5,7 +5,7 @@ from core.exchanges import common
from core.exchanges.convert import get_price, side_to_direction
from core.lib.notify import sendmsg
from core.models import Account, Strategy, Trade
from core.trading import assetfilter
from core.trading import assetfilter, checks
from core.trading.crossfilter import crossfilter
from core.trading.risk import check_risk
from core.util import logs