fix: 交易安全审计修复 — 补偿平仓、中控同步、滚仓/趋势防护

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-04 22:44:16 +08:00
parent df28e6dfb8
commit eb975b0133
11 changed files with 675 additions and 162 deletions
+6 -3
View File
@@ -453,8 +453,11 @@ def cancel_orders_for_symbol(
try:
cancel_order(ex, exchange_kind, symbol, o["id"], o.get("channel") or "regular")
n += 1
except Exception:
pass
except Exception as e:
print(
f"[cancel_orders_for_symbol] {exchange_kind} {symbol} id={o.get('id')}: {e}",
flush=True,
)
return n
@@ -655,7 +658,7 @@ def _gate_place_tp_sl_position(
try:
ex.privateFuturesPostSettlePriceOrders(_payload(tp_s, tp_rule))
except Exception:
cancel_orders_for_symbol(ex, "gate", symbol, scope="conditional")
# 保留已挂止损,仅放弃本次 TP
raise
return
except Exception as e: