Finish AMS tests

This commit is contained in:
2023-02-22 07:20:58 +00:00
parent ed63085e10
commit 9c537187f0
3 changed files with 279 additions and 50 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 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")
if len(strategy.trend_signals.all()) > 0:
if strategy.trends is None:
log.debug("Refusing to trade with no trend signals received")
sendmsg(
strategy.user,
f"Refusing to trade {symbol} against the trend",
title="Trend rejection",
f"Refusing to trade {symbol} with no trend signals received",
title="Trend not ready",
)
return False
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:
log.debug(f"Trend check passed for {symbol} - {direction}")
return True
else:
log.debug("No trend signals configured")
return True
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