diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index a0b773a16..d23ba270d 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -420,7 +420,7 @@ class FreqtradeBot(LoggingMixin): return False # running get_signal on historical data fetched - (buy, sell, buy_tag, exit_tag) = self.strategy.get_signal( + (buy, sell, buy_tag, _) = self.strategy.get_signal( pair, self.strategy.timeframe, analyzed_df @@ -707,7 +707,7 @@ class FreqtradeBot(LoggingMixin): analyzed_df, _ = self.dataprovider.get_analyzed_dataframe(trade.pair, self.strategy.timeframe) - (buy, sell, buy_tag, exit_tag) = self.strategy.get_signal( + (buy, sell, _, exit_tag) = self.strategy.get_signal( trade.pair, self.strategy.timeframe, analyzed_df diff --git a/tests/strategy/test_interface.py b/tests/strategy/test_interface.py index 62510b370..e8ee0bfed 100644 --- a/tests/strategy/test_interface.py +++ b/tests/strategy/test_interface.py @@ -30,7 +30,7 @@ _STRATEGY = StrategyTestV2(config={}) _STRATEGY.dp = DataProvider({}, None, None) -def test_returns_latest_signal(mocker, default_conf, ohlcv_history): +def test_returns_latest_signal(ohlcv_history): ohlcv_history.loc[1, 'date'] = arrow.utcnow() # Take a copy to correctly modify the call mocked_history = ohlcv_history.copy() @@ -60,6 +60,18 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history): 'buy_signal_01', None) + mocked_history.loc[1, 'buy_tag'] = None + mocked_history.loc[1, 'exit_tag'] = 'sell_signal_01' + + assert _STRATEGY.get_signal( + 'ETH/BTC', + '5m', + mocked_history) == ( + True, + False, + None, + 'sell_signal_01') + def test_analyze_pair_empty(default_conf, mocker, caplog, ohlcv_history): mocker.patch.object(_STRATEGY.dp, 'ohlcv', return_value=ohlcv_history) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index e590f4f74..0435dc3a2 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1808,7 +1808,7 @@ def test_handle_trade(default_conf_usdt, limit_buy_order_usdt, limit_sell_order_ assert trade.is_open is True freqtrade.wallets.update() - patch_get_signal(freqtrade, value=(False, True, None, None)) + patch_get_signal(freqtrade, value=(False, True, None, 'sell_signal1')) assert freqtrade.handle_trade(trade) is True assert trade.open_order_id == limit_sell_order_usdt['id'] @@ -1819,6 +1819,7 @@ def test_handle_trade(default_conf_usdt, limit_buy_order_usdt, limit_sell_order_ assert trade.close_profit == 0.09451372 assert trade.calc_profit() == 5.685 assert trade.close_date is not None + assert trade.sell_reason == 'sell_signal1' def test_handle_overlapping_signals(default_conf_usdt, ticker_usdt, limit_buy_order_usdt_open,