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:
@@ -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 [];
|
||||
|
||||
Reference in New Issue
Block a user