Convert nan to None in get_signal.
This commit is contained in:
parent
39184e1f95
commit
6c4b261469
@ -654,6 +654,9 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
|
||||
buy_tag = latest.get(SignalTagType.BUY_TAG.value, None)
|
||||
exit_tag = latest.get(SignalTagType.EXIT_TAG.value, None)
|
||||
# Tags can be None, which does not resolve to False.
|
||||
buy_tag = buy_tag if isinstance(buy_tag, str) else None
|
||||
exit_tag = exit_tag if isinstance(exit_tag, str) else None
|
||||
|
||||
logger.debug('trigger: %s (pair=%s) buy=%s sell=%s',
|
||||
latest['date'], pair, str(buy), str(sell))
|
||||
|
@ -36,6 +36,10 @@ def test_returns_latest_signal(ohlcv_history):
|
||||
mocked_history = ohlcv_history.copy()
|
||||
mocked_history['sell'] = 0
|
||||
mocked_history['buy'] = 0
|
||||
# Set tags in lines that don't matter to test nan in the sell line
|
||||
mocked_history.loc[0, 'buy_tag'] = 'wrong_line'
|
||||
mocked_history.loc[0, 'exit_tag'] = 'wrong_line'
|
||||
|
||||
mocked_history.loc[1, 'sell'] = 1
|
||||
|
||||
assert _STRATEGY.get_signal('ETH/BTC', '5m', mocked_history) == (False, True, None, None)
|
||||
|
Loading…
Reference in New Issue
Block a user