期权总览增加买一/流动性列,不足时标黄。

展示买一价与张数,深度不够或残档高亮提示。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-01 12:39:36 +08:00
parent 8236d1ef5a
commit 73905d236d
2 changed files with 62 additions and 1 deletions
+53 -1
View File
@@ -39,6 +39,55 @@
return "<ul class=\"pos-brief\">" + items.join("") + more + "</ul>";
}
function fmtBidPx(v) {
if (v == null || v === "") return "—";
const n = Number(v);
if (!Number.isFinite(n)) return "—";
let s = n.toFixed(4).replace(/\.?0+$/, "");
return s || "0";
}
function isLiquidityWeak(p) {
if (!p) return false;
if (p.liquidity_ok === false || p.bid_invalid) return true;
const uncovered = Number(p.uncovered_sheets);
return Number.isFinite(uncovered) && uncovered > 0;
}
function bidLiquidityLine(p) {
if (p.bid_invalid || (p.bid_px == null && (p.bid_sz == null || p.bid_sz === ""))) {
const reason = (p.bid_invalid_reason || "无买一/残档").toString();
const short = reason.length > 18 ? reason.slice(0, 18) + "…" : reason;
return { text: short, weak: true };
}
const px = fmtBidPx(p.bid_px);
const sz = p.bid_sz != null ? String(p.bid_sz) : "—";
const uncovered = Number(p.uncovered_sheets);
let text = px + " / " + sz + "张";
const weak = isLiquidityWeak(p);
if (Number.isFinite(uncovered) && uncovered > 0) {
text += "(差" + uncovered + ")";
}
return { text: text, weak: weak };
}
function bidLiquiditySummary(brief) {
const list = brief || [];
if (!list.length) return '<span class="muted">—</span>';
const items = list.slice(0, 8).map(function (p) {
const line = bidLiquidityLine(p);
const cls = line.weak ? "liq-warn" : "liq-ok";
return '<li class="' + cls + '">' + escapeHtml(line.text) + "</li>";
});
const more =
list.length > 8
? '<li class="muted">…共 ' + list.length + " 笔</li>"
: "";
const anyWeak = list.some(isLiquidityWeak);
const wrapCls = anyWeak ? "pos-brief liq-brief liq-brief--warn" : "pos-brief liq-brief";
return '<ul class="' + wrapCls + '">' + items.join("") + more + "</ul>";
}
function renderRow(row) {
const snap = row.snapshot || {};
const inst = snap.instance || {};
@@ -73,6 +122,9 @@
"<td>" +
positionSummary(brief) +
"</td>" +
"<td>" +
bidLiquiditySummary(brief) +
"</td>" +
'<td class="muted">' +
escapeHtml(row.pulled_at || "—") +
"</td>" +
@@ -105,7 +157,7 @@
grid.innerHTML =
'<div class="overview-table-wrap"><table class="overview-table">' +
"<thead><tr>" +
"<th>名称</th><th>状态</th><th>模式</th><th>浮盈</th><th>持仓</th><th>拉取时间</th><th>操作</th>" +
"<th>名称</th><th>状态</th><th>模式</th><th>浮盈</th><th>持仓</th><th>买一/流动性</th><th>拉取时间</th><th>操作</th>" +
"</tr></thead><tbody>" +
list.map(renderRow).join("") +
"</tbody></table></div>";