Write crossfilter, asset groups and max open trades implementation and tests
This commit is contained in:
@@ -49,7 +49,7 @@ def check_max_open_trades(risk_model, account_trades):
|
||||
return len(account_trades) < risk_model.max_open_trades
|
||||
|
||||
|
||||
def check_max_open_trades_per_symbol(risk_model, account_trades):
|
||||
def check_max_open_trades_per_symbol(risk_model, account_trades, yield_symbol=False):
|
||||
"""
|
||||
Check we cannot open more trades per symbol than permissible.
|
||||
"""
|
||||
@@ -62,8 +62,12 @@ def check_max_open_trades_per_symbol(risk_model, account_trades):
|
||||
|
||||
for symbol, count in symbol_map.items():
|
||||
if count >= risk_model.max_open_trades_per_symbol:
|
||||
return False
|
||||
return True
|
||||
if yield_symbol:
|
||||
yield symbol
|
||||
else:
|
||||
return False
|
||||
if not yield_symbol:
|
||||
return True
|
||||
|
||||
|
||||
def check_risk(risk_model, account, proposed_trade):
|
||||
|
||||
Reference in New Issue
Block a user