diff --git a/static/hub.css b/static/hub.css index 82c6460..65b04be 100644 --- a/static/hub.css +++ b/static/hub.css @@ -719,6 +719,49 @@ button, .btn { color: #6ee7b7; background: rgba(52, 211, 153, 0.14); } +.overview-table td strong { + display: inline-block; + margin-right: 8px; + vertical-align: middle; +} +.overview-cond-tag { + display: inline-block; + margin-top: 4px; + padding: 2px 8px; + border-radius: 999px; + font-size: 0.72rem; + font-weight: 700; + white-space: nowrap; + vertical-align: middle; +} +.overview-cond-tag.is-armed { + color: #7dd3fc; + background: rgba(56, 189, 248, 0.16); +} +.overview-cond-tag.is-trig { + color: #fbbf24; + background: rgba(251, 191, 36, 0.16); +} +.overview-cond-tag.is-open { + color: #6ee7b7; + background: rgba(52, 211, 153, 0.16); +} +.overview-cond-wait-line { + color: #9ec0ff; + font-size: 0.8rem; + font-weight: 600; +} +.overview-cond-src { + display: inline-block; + margin-left: 6px; + padding: 0 6px; + border-radius: 999px; + font-size: 0.68rem; + font-weight: 700; + color: #7dd3fc; + background: rgba(56, 189, 248, 0.14); + vertical-align: middle; +} .pos-brief { margin: 0; padding-left: 0; diff --git a/static/hub.js b/static/hub.js index 5c81684..b461bb1 100644 --- a/static/hub.js +++ b/static/hub.js @@ -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 ( + '条件单 · ' + + escapeHtml(condStatusLabel(st)) + + "" + ); + } + + 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 '暂无持仓'; + if (!list.length) { + if (cond) { + return ( + '
' + + '
' + + escapeHtml(condWaitLine(cond)) + + "
" + ); + } + return '暂无持仓'; + } + 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 ( "
  • " + escapeHtml(id) + @@ -59,6 +120,7 @@ sheets + "张 · " + fmtPnlHtml(p.pnl_usdt) + + (fromCond ? '条件单' : "") + "
  • " ); }); @@ -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 ? '在线' @@ -249,6 +312,7 @@ "" + escapeHtml(row.name || "") + "" + + condTagHtml(cond) + err + "" + "" + @@ -279,7 +343,7 @@ premiumRatioCell(snap) + "" + "" + - positionSummary(brief) + + positionSummary(brief, cond) + "" + "" + exitSummary(brief) + diff --git a/templates/base.html b/templates/base.html index 4c97256..d44ebe4 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,7 +4,7 @@ {% block title %}期权中控{% endblock %} - + {% if session.get('logged_in') %} diff --git a/templates/dashboard.html b/templates/dashboard.html index b45d6c5..a046315 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -15,6 +15,6 @@
    {% endblock %} {% block scripts %} - + {% endblock %}