fix: use "triggered order" id where necessary

closes  #12680
This commit is contained in:
Matthias
2026-01-02 16:37:12 +01:00
parent f82d2fe796
commit 58130572a9
3 changed files with 11 additions and 11 deletions

View File

@@ -2392,6 +2392,16 @@ class Exchange:
raise OperationalException(e) from e
def get_order_id_conditional(self, order: CcxtOrder) -> str:
"""
Return order id or id_stop (for conditional orders) based on exchange settings
:param order: ccxt order dict
:return: correct order id
"""
if self.get_option("stoploss_query_requires_stop_flag") and (
order["type"] in ("stoploss", "stop")
):
return safe_value_fallback(order, "id_stop", "id")
return order["id"]
@retrier

View File

@@ -10,8 +10,7 @@ from freqtrade.enums import MarginMode, PriceType, TradingMode
from freqtrade.exceptions import DDosProtection, OperationalException, TemporaryError
from freqtrade.exchange import Exchange
from freqtrade.exchange.common import retrier
from freqtrade.exchange.exchange_types import CcxtOrder, FtHas
from freqtrade.misc import safe_value_fallback2
from freqtrade.exchange.exchange_types import FtHas
logger = logging.getLogger(__name__)
@@ -132,6 +131,3 @@ class Gate(Exchange):
"rate": pair_fees[takerOrMaker],
}
return trades
def get_order_id_conditional(self, order: CcxtOrder) -> str:
return safe_value_fallback2(order, order, "id_stop", "id")

View File

@@ -14,7 +14,6 @@ from freqtrade.exceptions import (
from freqtrade.exchange import Exchange
from freqtrade.exchange.common import API_RETRY_COUNT, retrier
from freqtrade.exchange.exchange_types import CcxtOrder, FtHas
from freqtrade.misc import safe_value_fallback2
from freqtrade.util import dt_now, dt_ts
@@ -259,11 +258,6 @@ class Okx(Exchange):
raise OperationalException(e) from e
raise RetryableOrderError(f"StoplossOrder not found (pair: {pair} id: {order_id}).")
def get_order_id_conditional(self, order: CcxtOrder) -> str:
if order.get("type", "") == "stop":
return safe_value_fallback2(order, order, "id_stop", "id")
return order["id"]
def _fetch_orders_emulate(self, pair: str, since_ms: int) -> list[CcxtOrder]:
orders = []