fix: 中控改委托后同步计划价并去重条件单展示

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-04 21:12:00 +08:00
parent 54c1984ec7
commit be51eee73f
8 changed files with 376 additions and 33 deletions
+4 -23
View File
@@ -8,6 +8,7 @@ import time
from typing import Any
from lib.exchange.okx_orders_lib import fetch_okx_all_open_orders
from lib.hub.hub_symbol_lib import symbols_match
def _coerce_float(*values) -> float | None:
@@ -37,28 +38,6 @@ def _symbol_base_coin(symbol: str) -> str:
return s
def symbols_match(position_symbol: str, order_symbol: str) -> bool:
a = (position_symbol or "").strip().upper()
b = (order_symbol or "").strip().upper()
if not a or not b:
return False
if a == b:
return True
ba, bb = _symbol_base_coin(a), _symbol_base_coin(b)
if ba and bb and ba == bb:
return True
for suf in (":USDT", "/USDT:USDT", "/USDT"):
a2 = a.replace(suf, "")
b2 = b.replace(suf, "")
if f"{a2}/USDT" == b or f"{a2}/USDT:USDT" == b:
return True
if f"{b2}/USDT" == a or f"{b2}/USDT:USDT" == a:
return True
if a2 == b2:
return True
return False
def _order_type_str(order: dict) -> str:
info = order.get("info") or {}
if isinstance(info, dict):
@@ -424,7 +403,9 @@ def attach_orders_to_positions(positions: list[dict], orders: list[dict]) -> Non
matched = [o for o in orders if symbols_match(sym, o.get("symbol") or "")]
cond = [o for o in matched if o.get("category") == "conditional"]
_enrich_gate_conditional_labels(cond, p.get("side") or "long")
p["conditional_orders"] = cond
from lib.hub.hub_order_sync_lib import dedupe_conditional_orders_by_role
p["conditional_orders"] = dedupe_conditional_orders_by_role(cond)
p["regular_orders"] = [o for o in matched if o.get("category") != "conditional"]