fix(hub,gate): cross-margin TP/SL and dedupe hub conditional orders

Gate hedge position triggers use close=false; stop silent ccxt fallback on cross margin. Hub merges agent and Flask TP/SL by trigger price and labels Gate orders correctly.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 19:48:04 +08:00
parent ed0805538f
commit 24270944e7
7 changed files with 220 additions and 25 deletions
+22 -1
View File
@@ -896,8 +896,29 @@
return localStorage.getItem(ordersCollapseKey(exchangeId, symbol)) === "1";
}
function dedupeCondOrdersByTrigger(orders) {
const list = Array.isArray(orders) ? orders : [];
const seen = new Set();
const out = [];
for (const o of list) {
const px = orderTriggerOrPrice(o);
const key =
px != null
? "t:" + String(px)
: o && o.id
? "id:" + String(o.id)
: null;
if (key && seen.has(key)) continue;
if (key) seen.add(key);
out.push(o);
}
return out;
}
function condOrdersFromPosition(pos) {
const cond = Array.isArray(pos.conditional_orders) ? pos.conditional_orders : [];
const cond = dedupeCondOrdersByTrigger(
Array.isArray(pos.conditional_orders) ? pos.conditional_orders : []
);
if (cond.length) return cond;
const et = pos.exchange_tpsl;
if (!et) return [];