diff --git a/freqtrade/resolvers/strategy_resolver.py b/freqtrade/resolvers/strategy_resolver.py index 71de94b1d..456e0fee1 100644 --- a/freqtrade/resolvers/strategy_resolver.py +++ b/freqtrade/resolvers/strategy_resolver.py @@ -227,7 +227,7 @@ class StrategyResolver(IResolver): if type(strategy).populate_exit_trend == IStrategy.populate_exit_trend: raise OperationalException("`populate_exit_trend` must be implemented.") else: - + # TODO: Implementing buy_trend and sell_trend should raise a deprecation. if (type(strategy).populate_buy_trend == IStrategy.populate_buy_trend and type(strategy).populate_entry_trend == IStrategy.populate_entry_trend): raise OperationalException( diff --git a/tests/strategy/strats/broken_strats/broken_futures_strategies.py b/tests/strategy/strats/broken_strats/broken_futures_strategies.py new file mode 100644 index 000000000..42f631b97 --- /dev/null +++ b/tests/strategy/strats/broken_strats/broken_futures_strategies.py @@ -0,0 +1,16 @@ +# The strategy which fails to load due to non-existent dependency + +from pandas import DataFrame + +from freqtrade.strategy.interface import IStrategy + + +class TestStrategyNoImplements(IStrategy): + + def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + return super().populate_indicators(dataframe, metadata) + + +class TestStrategyNoImplementSell(TestStrategyNoImplements): + def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + return super().populate_entry_trend(dataframe, metadata) diff --git a/tests/strategy/test_strategy_loading.py b/tests/strategy/test_strategy_loading.py index 97e915bb0..955db038b 100644 --- a/tests/strategy/test_strategy_loading.py +++ b/tests/strategy/test_strategy_loading.py @@ -391,6 +391,32 @@ def test_deprecate_populate_indicators(result, default_conf): in str(w[-1].message) +@pytest.mark.filterwarnings("ignore:deprecated") +def test_missing_implements(result, default_conf): + default_location = Path(__file__).parent / "strats/broken_strats" + default_conf.update({'strategy': 'TestStrategyNoImplements', + 'strategy_path': default_location}) + with pytest.raises(OperationalException, + match=r"`populate_entry_trend` or `populate_buy_trend`.*"): + StrategyResolver.load_strategy(default_conf) + + default_conf['strategy'] = 'TestStrategyNoImplementSell' + + with pytest.raises(OperationalException, + match=r"`populate_exit_trend` or `populate_sell_trend`.*"): + StrategyResolver.load_strategy(default_conf) + + default_conf['trading_mode'] = 'futures' + + with pytest.raises(OperationalException, + match=r"`populate_exit_trend` must be implemented.*"): + StrategyResolver.load_strategy(default_conf) + + default_conf['strategy'] = 'TestStrategyNoImplements' + with pytest.raises(OperationalException, + match=r"`populate_entry_trend` must be implemented.*"): + StrategyResolver.load_strategy(default_conf) + @pytest.mark.filterwarnings("ignore:deprecated") def test_call_deprecated_function(result, default_conf, caplog): default_location = Path(__file__).parent / "strats"