diff --git a/freqtrade/constants.py b/freqtrade/constants.py index 318c414e1..265cfd5d5 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -77,7 +77,8 @@ DL_DATA_TIMEFRAMES = ['1m', '5m'] ENV_VAR_PREFIX = 'FREQTRADE__' -NON_OPEN_EXCHANGE_STATES = ('cancelled', 'canceled', 'closed', 'expired') +CANCELED_EXCHANGE_STATES = ('cancelled', 'canceled', 'expired') +NON_OPEN_EXCHANGE_STATES = CANCELED_EXCHANGE_STATES + ('closed',) # Define decimals per coin for outputs # Only used for outputs. diff --git a/freqtrade/persistence/trade_model.py b/freqtrade/persistence/trade_model.py index 679c160ad..9d727ab75 100644 --- a/freqtrade/persistence/trade_model.py +++ b/freqtrade/persistence/trade_model.py @@ -13,8 +13,9 @@ from sqlalchemy import (Enum, Float, ForeignKey, Integer, ScalarResult, Select, from sqlalchemy.orm import Mapped, lazyload, mapped_column, relationship, validates from typing_extensions import Self -from freqtrade.constants import (CUSTOM_TAG_MAX_LENGTH, DATETIME_PRINT_FORMAT, MATH_CLOSE_PREC, - NON_OPEN_EXCHANGE_STATES, BuySell, LongShort) +from freqtrade.constants import (CANCELED_EXCHANGE_STATES, CUSTOM_TAG_MAX_LENGTH, + DATETIME_PRINT_FORMAT, MATH_CLOSE_PREC, NON_OPEN_EXCHANGE_STATES, + BuySell, LongShort) from freqtrade.enums import ExitType, TradingMode from freqtrade.exceptions import DependencyException, OperationalException from freqtrade.exchange import (ROUND_DOWN, ROUND_UP, amount_to_contract_precision, @@ -827,7 +828,8 @@ class LocalTrade: Get amount of failed exiting orders assumes full exits. """ - return len([o for o in self.orders if o.ft_order_side == self.exit_side]) + return len([o for o in self.orders if o.ft_order_side == self.exit_side + and o.status in CANCELED_EXCHANGE_STATES]) def _calc_open_trade_value(self, amount: float, open_rate: float) -> float: """