Separate live tests for active management

This commit is contained in:
2023-02-22 07:20:21 +00:00
parent 9c537187f0
commit 682c42c0e8
3 changed files with 153 additions and 102 deletions

View File

@@ -46,34 +46,34 @@ def within_callback_price_deviation(strategy, price, current_price):
def within_trends(strategy, symbol, direction):
if strategy.trend_signals.exists():
if len(strategy.trend_signals.all()) > 0:
if strategy.trends is None:
log.debug("Refusing to trade with no trend signals received")
if strategy.trends is None:
log.debug("Refusing to trade with no trend signals received")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} with no trend signals received",
title="Trend not ready",
)
return None
if symbol not in strategy.trends:
log.debug("Refusing to trade asset without established trend")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} without established trend",
title="Trend not ready",
)
return None
else:
if strategy.trends[symbol] != direction:
log.debug("Refusing to trade against the trend")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} with no trend signals received",
title="Trend not ready",
f"Refusing to trade {symbol} against the trend",
title="Trend rejection",
)
return None
if symbol not in strategy.trends:
log.debug("Refusing to trade asset without established trend")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} without established trend",
title="Trend not ready",
)
return None
return False
else:
if strategy.trends[symbol] != direction:
log.debug("Refusing to trade against the trend")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} against the trend",
title="Trend rejection",
)
return False
else:
log.debug(f"Trend check passed for {symbol} - {direction}")
return True
log.debug("No trend signals configured")
return True
log.debug(f"Trend check passed for {symbol} - {direction}")
return True
else:
log.debug("No trend signals configured")
return True