From 84e5a9521de6a4841d64267e71c01c65dcd23763 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 22 Dec 2024 20:11:32 +0100 Subject: [PATCH] chore: improve left open trades handling --- freqtrade/optimize/backtesting.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index d3b8cfce3..ba9408697 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -1166,9 +1166,13 @@ class Backtesting: """ for pair in open_trades.keys(): for trade in list(open_trades[pair]): - if trade.has_open_orders and trade.nr_of_successful_entries == 0: + if ( + trade.has_open_orders and trade.nr_of_successful_entries == 0 + ) or not not trade.has_open_position: # Ignore trade if entry-order did not fill yet + LocalTrade.remove_bt_trade(trade) continue + exit_row = data[pair][-1] self._exit_trade( trade, exit_row, exit_row[OPEN_IDX], trade.amount, ExitType.FORCE_EXIT.value