From 9f445cb0532fd5afc2064a978aff0b971e7c0db1 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 21 Sep 2023 06:45:37 +0200 Subject: [PATCH] Don't rely on status when determining open order count --- freqtrade/freqtradebot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 181ffb609..d02350255 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -1516,8 +1516,10 @@ class FreqtradeBot(LoggingMixin): filled_amount = safe_value_fallback2(corder, order, 'filled', 'filled') if isclose(filled_amount, 0.0, abs_tol=constants.MATH_CLOSE_PREC): # if trade is not partially completed and it's the only order, just delete the trade - open_order_count = len([order for order in trade.orders if order.status == 'open']) - if open_order_count <= 1 and trade.nr_of_successful_entries == 0 and not replacing: + open_order_count = len([ + order for order in trade.orders if order.ft_is_open and order.order_id != order_id + ]) + if open_order_count < 1 and trade.nr_of_successful_entries == 0 and not replacing: logger.info(f'{side} order fully cancelled. Removing {trade} from database.') trade.delete() was_trade_fully_canceled = True