Don't rely on status when determining open order count

This commit is contained in:
Matthias 2023-09-21 06:45:37 +02:00
parent 1d23ba6e30
commit 9f445cb053

View File

@ -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