总览增加权利金与资金占比两列。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-02 16:13:37 +08:00
parent f7f0cf3ac8
commit 5a3904ad85
+58 -1
View File
@@ -132,6 +132,57 @@
return '<ul class="' + wrapCls + '">' + items.join("") + more + "</ul>"; return '<ul class="' + wrapCls + '">' + items.join("") + more + "</ul>";
} }
function fmtMoneyU(v) {
if (v == null || v === "") return "—";
const n = Number(v);
if (!Number.isFinite(n)) return "—";
return n.toFixed(2) + " U";
}
function fmtRatioPct(v) {
if (v == null || v === "") return "—";
const n = Number(v);
if (!Number.isFinite(n)) return "—";
return n.toFixed(2) + "%";
}
function premiumCell(snap) {
const prem = snap.premium || {};
const paid = prem.paid_usdt;
const equity = prem.equity_usdt;
const ratio = prem.ratio_pct;
const tip =
equity != null
? "账户资金(资+交) " + fmtMoneyU(equity)
: "账户资金暂无";
return (
'<span title="' +
escapeHtml(tip) +
'">' +
escapeHtml(fmtMoneyU(paid)) +
"</span>"
);
}
function premiumRatioCell(snap) {
const prem = snap.premium || {};
const ratio = prem.ratio_pct;
const tip =
prem.paid_usdt != null && prem.equity_usdt != null
? "权利金 " +
fmtMoneyU(prem.paid_usdt) +
" / 账户 " +
fmtMoneyU(prem.equity_usdt)
: "";
return (
'<span title="' +
escapeHtml(tip) +
'">' +
escapeHtml(fmtRatioPct(ratio)) +
"</span>"
);
}
function renderRow(row) { function renderRow(row) {
const snap = row.snapshot || {}; const snap = row.snapshot || {};
const inst = snap.instance || {}; const inst = snap.instance || {};
@@ -164,6 +215,12 @@
fmtPnlHtml(pnl) + fmtPnlHtml(pnl) +
"</td>" + "</td>" +
"<td>" + "<td>" +
premiumCell(snap) +
"</td>" +
"<td>" +
premiumRatioCell(snap) +
"</td>" +
"<td>" +
positionSummary(brief) + positionSummary(brief) +
"</td>" + "</td>" +
"<td>" + "<td>" +
@@ -248,7 +305,7 @@
grid.innerHTML = grid.innerHTML =
'<div class="overview-table-wrap"><table class="overview-table">' + '<div class="overview-table-wrap"><table class="overview-table">' +
"<thead><tr>" + "<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><th>买一/流动性</th><th>拉取时间</th><th>操作</th>" +
"</tr></thead><tbody>" + "</tr></thead><tbody>" +
list.map(renderRow).join("") + list.map(renderRow).join("") +
"</tbody></table></div>"; "</tbody></table></div>";