diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index b97821c00..a4bb007f1 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -1133,8 +1133,6 @@ class IStrategy(ABC, HyperStrategyMixin): message = "" if dataframe is None: message = "No dataframe returned (return statement missing?)." - elif "enter_long" not in dataframe: - message = "enter_long/buy column not set." elif df_len != len(dataframe): message = message_template.format("length") elif df_close != dataframe["close"].iloc[-1]: @@ -1206,7 +1204,7 @@ class IStrategy(ABC, HyperStrategyMixin): exit_ = latest.get(SignalType.EXIT_SHORT.value, 0) == 1 else: - enter = latest[SignalType.ENTER_LONG.value] == 1 + enter = latest.get(SignalType.ENTER_LONG.value, 0) == 1 exit_ = latest.get(SignalType.EXIT_LONG.value, 0) == 1 exit_tag = latest.get(SignalTagType.EXIT_TAG.value, None) # Tags can be None, which does not resolve to False. @@ -1235,7 +1233,7 @@ class IStrategy(ABC, HyperStrategyMixin): if latest is None or latest_date is None: return None, None - enter_long = latest[SignalType.ENTER_LONG.value] == 1 + enter_long = latest.get(SignalType.ENTER_LONG.value, 0) == 1 exit_long = latest.get(SignalType.EXIT_LONG.value, 0) == 1 enter_short = latest.get(SignalType.ENTER_SHORT.value, 0) == 1 exit_short = latest.get(SignalType.EXIT_SHORT.value, 0) == 1 diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index 5459a0ff2..441eb5673 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -296,13 +296,6 @@ def test_assert_df(ohlcv_history, caplog): ohlcv_history.loc[df_len, "close"], ohlcv_history.loc[0, "date"], ) - with pytest.raises(StrategyError, match="enter_long/buy column not set."): - _STRATEGY.assert_df( - ohlcv_history.drop("enter_long", axis=1), - len(ohlcv_history), - ohlcv_history.loc[df_len, "close"], - ohlcv_history.loc[0, "date"], - ) _STRATEGY.disable_dataframe_checks = True caplog.clear()