fix: 中控改委托后同步计划价并去重条件单展示
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1831,6 +1831,29 @@
|
||||
return localStorage.getItem(ordersCollapseKey(exchangeId, symbol)) === "1";
|
||||
}
|
||||
|
||||
function condOrderRole(o) {
|
||||
const lb = (o && o.label) || "";
|
||||
if (/止盈止损/.test(lb)) return null;
|
||||
if (/止损/.test(lb)) return "sl";
|
||||
if (/止盈/.test(lb)) return "tp";
|
||||
return null;
|
||||
}
|
||||
|
||||
function dedupeCondOrdersByRole(orders) {
|
||||
const list = Array.isArray(orders) ? orders : [];
|
||||
const byRole = {};
|
||||
const others = [];
|
||||
for (const o of list) {
|
||||
const role = condOrderRole(o);
|
||||
if (role) byRole[role] = o;
|
||||
else others.push(o);
|
||||
}
|
||||
const out = others.slice();
|
||||
if (byRole.tp) out.push(byRole.tp);
|
||||
if (byRole.sl) out.push(byRole.sl);
|
||||
return out;
|
||||
}
|
||||
|
||||
function dedupeCondOrdersByTrigger(orders) {
|
||||
const list = Array.isArray(orders) ? orders : [];
|
||||
const seen = new Set();
|
||||
@@ -1869,9 +1892,10 @@
|
||||
}
|
||||
|
||||
function condOrdersFromPosition(pos) {
|
||||
const cond = dedupeCondOrdersByTrigger(
|
||||
let cond = dedupeCondOrdersByRole(
|
||||
Array.isArray(pos.conditional_orders) ? pos.conditional_orders : []
|
||||
);
|
||||
cond = dedupeCondOrdersByTrigger(cond);
|
||||
const et = pos.exchange_tpsl;
|
||||
if (!et) return cond;
|
||||
upsertExTpslCondOrder(cond, "sl", et.sl);
|
||||
|
||||
Reference in New Issue
Block a user