总览名称旁增加条件单标签,无仓时持仓列显示触发短文案。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+67
-3
@@ -46,12 +46,73 @@
|
||||
return parts.length ? parts.join(" · ") : "未设出场";
|
||||
}
|
||||
|
||||
function positionSummary(brief) {
|
||||
function activeCondOrder(snap) {
|
||||
const list = snap && snap.cond_orders_active;
|
||||
if (Array.isArray(list) && list.length && list[0]) return list[0];
|
||||
if (snap && snap.cond_order) return snap.cond_order;
|
||||
if (snap && snap.cond_order_locked) return { status: "armed" };
|
||||
return null;
|
||||
}
|
||||
|
||||
function condStatusLabel(st) {
|
||||
const map = { armed: "待命", triggering: "触发中", open: "持仓中" };
|
||||
return map[st] || "占用";
|
||||
}
|
||||
|
||||
function condStatusClass(st) {
|
||||
if (st === "open") return "is-open";
|
||||
if (st === "triggering") return "is-trig";
|
||||
return "is-armed";
|
||||
}
|
||||
|
||||
function condTagHtml(cond) {
|
||||
if (!cond) return "";
|
||||
const st = String(cond.status || "armed");
|
||||
return (
|
||||
'<span class="overview-cond-tag ' +
|
||||
condStatusClass(st) +
|
||||
'">条件单 · ' +
|
||||
escapeHtml(condStatusLabel(st)) +
|
||||
"</span>"
|
||||
);
|
||||
}
|
||||
|
||||
function condWaitLine(cond) {
|
||||
if (!cond) return "条件单占用";
|
||||
const put = String(cond.opt_type || "").toUpperCase() !== "C";
|
||||
const uly = String(cond.underlying || "").trim();
|
||||
const side =
|
||||
String(cond.trigger_side || "").toLowerCase() === "lte"
|
||||
? "下穿 ≤"
|
||||
: put
|
||||
? "上穿 ≥"
|
||||
: "下穿 ≤";
|
||||
const px = cond.trigger_px != null && cond.trigger_px !== "" ? String(cond.trigger_px) : "";
|
||||
const bits = [];
|
||||
if (uly) bits.push(uly + " " + (put ? "Put" : "Call"));
|
||||
if (px) bits.push(side + " " + px);
|
||||
return bits.length ? bits.join(" · ") : "条件单占用";
|
||||
}
|
||||
|
||||
function positionSummary(brief, cond) {
|
||||
const list = brief || [];
|
||||
if (!list.length) return '<span class="muted">暂无持仓</span>';
|
||||
if (!list.length) {
|
||||
if (cond) {
|
||||
return (
|
||||
'<div class="overview-cond-wait">' +
|
||||
'<div class="overview-cond-wait-line">' +
|
||||
escapeHtml(condWaitLine(cond)) +
|
||||
"</div></div>"
|
||||
);
|
||||
}
|
||||
return '<span class="muted">暂无持仓</span>';
|
||||
}
|
||||
const opened = cond && String(cond.opened_inst_id || "").trim();
|
||||
const tagOpen = !!(cond && String(cond.status || "") === "open");
|
||||
const items = list.slice(0, 8).map(function (p) {
|
||||
const id = p.inst_id || "";
|
||||
const sheets = escapeHtml(String(p.sheets != null ? p.sheets : "—"));
|
||||
const fromCond = tagOpen && (!opened || opened === id);
|
||||
return (
|
||||
"<li>" +
|
||||
escapeHtml(id) +
|
||||
@@ -59,6 +120,7 @@
|
||||
sheets +
|
||||
"张 · " +
|
||||
fmtPnlHtml(p.pnl_usdt) +
|
||||
(fromCond ? '<span class="overview-cond-src">条件单</span>' : "") +
|
||||
"</li>"
|
||||
);
|
||||
});
|
||||
@@ -237,6 +299,7 @@
|
||||
? snap.pnl.unrealized_usdt
|
||||
: snap.upl_total_usdc;
|
||||
const brief = snap.positions_brief || snap.positions || [];
|
||||
const cond = activeCondOrder(snap);
|
||||
const online = !!row.online;
|
||||
const status = online
|
||||
? '<span class="status-on">在线</span>'
|
||||
@@ -249,6 +312,7 @@
|
||||
"<td><strong>" +
|
||||
escapeHtml(row.name || "") +
|
||||
"</strong>" +
|
||||
condTagHtml(cond) +
|
||||
err +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
@@ -279,7 +343,7 @@
|
||||
premiumRatioCell(snap) +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
positionSummary(brief) +
|
||||
positionSummary(brief, cond) +
|
||||
"</td>" +
|
||||
"<td>" +
|
||||
exitSummary(brief) +
|
||||
|
||||
Reference in New Issue
Block a user