Begin work on scheduling management command
This commit is contained in:
3
core/trading/active_management.py
Normal file
3
core/trading/active_management.py
Normal file
@@ -0,0 +1,3 @@
|
||||
class ActiveManagement(object):
|
||||
def __init__(self, strategy):
|
||||
self.strategy = strategy
|
||||
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
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user