修复okx止盈止损

This commit is contained in:
dekun
2026-05-25 11:19:33 +08:00
parent 4e8498f736
commit 436d2aef6c
3 changed files with 85 additions and 14 deletions
+19 -2
View File
@@ -410,10 +410,27 @@
</details>`;
}
function pickExTpslOrders(cond) {
let sl = cond.find((o) => /^止损\b/.test(o.label || ""));
let tp = cond.find((o) => /^止盈\b/.test(o.label || "") && !(o.label || "").includes("止盈止损"));
if (!sl || !tp) {
const combo = cond.find((o) => (o.label || "").includes("止盈止损"));
if (combo) {
const m = (combo.label || "").match(/SL=([\d.eE+-]+).*TP=([\d.eE+-]+)/i);
if (m) {
if (!sl) sl = { ...combo, label: "止损", trigger_price: Number(m[1]) };
if (!tp) tp = { ...combo, label: "止盈", trigger_price: Number(m[2]) };
}
}
}
if (!sl) sl = cond.find((o) => (o.label || "").includes("止损"));
if (!tp) tp = cond.find((o) => (o.label || "").includes("止盈") && o !== sl);
return { sl, tp };
}
function renderExTpslRows(exchangeId, symbol, cond) {
const symAttr = esc(symbol || "").replace(/"/g, "&quot;");
const sl = cond.find((o) => (o.label || "").includes("止损"));
const tp = cond.find((o) => (o.label || "").includes("止盈"));
const { sl, tp } = pickExTpslOrders(cond);
function row(label, o) {
if (!o) {
return `<div class="pos-ex-order-row"><span class="pos-ex-order-main">${label}:—</span></div>`;