From dea7e3db014f2d8b1888035185b33ac98e37152c Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 14 Jun 2020 07:16:56 +0200 Subject: [PATCH] Use supress_errors in strategy wrapper - ensure it's called once --- freqtrade/freqtradebot.py | 2 +- tests/test_freqtradebot.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index a69178691..77ded8355 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -151,7 +151,7 @@ class FreqtradeBot: self.dataprovider.refresh(self.pairlists.create_pair_list(self.active_pair_whitelist), self.strategy.informative_pairs()) - strategy_safe_wrapper(self.strategy.bot_loop_start)() + strategy_safe_wrapper(self.strategy.bot_loop_start, supress_error=True)() self.strategy.analyze(self.active_pair_whitelist) diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index e83ac2038..381531eba 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -1964,6 +1964,18 @@ def test_close_trade(default_conf, ticker, limit_buy_order, limit_sell_order, freqtrade.handle_trade(trade) +def test_bot_loop_start_called_once(mocker, default_conf, caplog): + ftbot = get_patched_freqtradebot(mocker, default_conf) + patch_get_signal(ftbot) + ftbot.strategy.bot_loop_start = MagicMock(side_effect=ValueError) + ftbot.strategy.analyze = MagicMock() + + ftbot.process() + assert log_has_re(r'Strategy caused the following exception.*', caplog) + assert ftbot.strategy.bot_loop_start.call_count == 1 + assert ftbot.strategy.analyze.call_count == 1 + + def test_check_handle_timedout_buy_usercustom(default_conf, ticker, limit_buy_order_old, open_trade, fee, mocker) -> None: default_conf["unfilledtimeout"] = {"buy": 1400, "sell": 30}