diff --git a/manual_trading_hub/static/app.js b/manual_trading_hub/static/app.js
index cdb0ebb..6edc62a 100644
--- a/manual_trading_hub/static/app.js
+++ b/manual_trading_hub/static/app.js
@@ -13,6 +13,8 @@
return displayPref("show_account_pnl", true);
}
+ window.hubShowAccountPnlPref = showAccountPnlPref;
+
function showNavFundsPref() {
return displayPref("show_nav_funds", true);
}
@@ -5187,6 +5189,9 @@
loadSettingsMetaLine();
}
if (lastMonitorRows.length) renderMonitorGrid(lastMonitorRows);
+ if (window.hubDashboardPage && window.hubDashboardPage.refresh) {
+ window.hubDashboardPage.refresh();
+ }
if (!pageNavAllowed(currentPage())) {
history.replaceState({}, "", "/monitor");
setActiveNav();
diff --git a/manual_trading_hub/static/dashboard.js b/manual_trading_hub/static/dashboard.js
index 560cb9b..450742e 100644
--- a/manual_trading_hub/static/dashboard.js
+++ b/manual_trading_hub/static/dashboard.js
@@ -54,8 +54,16 @@
elStatus.className = "dash-status" + (isErr ? " err" : "");
}
+ function showAccountPnlPref() {
+ if (typeof window.hubShowAccountPnlPref === "function") {
+ return !!window.hubShowAccountPnlPref();
+ }
+ return true;
+ }
+
function renderKpi(totals) {
if (!elKpi || !totals) return;
+ const showPnl = showAccountPnlPref();
const closed = Number(totals.total_pnl_u);
const floating = Number(totals.float_pnl_u);
const funding = totals.total_funding_usdt;
@@ -68,16 +76,20 @@
totals.perpetual_open_position_count != null
? Number(totals.perpetual_open_position_count) || 0
: Math.max(0, totalPos - optPos);
- const items = [
- kpiItem("交易日", esc(totals.trading_day || "—")),
- kpiItem("资金合计", Number.isFinite(funds) ? `${fmt(funds, 2)}U` : "—"),
+ const items = [kpiItem("交易日", esc(totals.trading_day || "—"))];
+ if (showPnl) {
+ items.push(kpiItem("资金合计", Number.isFinite(funds) ? `${fmt(funds, 2)}U` : "—"));
+ }
+ items.push(
kpiItem("总持仓数量", `${totalPos}`),
kpiItem("期权持仓", `${optPos}`),
kpiItem("永续持仓", `${perpPos}`),
kpiItem("平仓数量", `${totals.closed_count || 0}`),
- kpiItem("平仓盈亏", pnlSigned(closed, 2), pnlClass(closed)),
- kpiItem("浮盈亏", pnlSigned(floating, 2), pnlClass(floating)),
- ];
+ kpiItem("平仓盈亏", pnlSigned(closed, 2), pnlClass(closed))
+ );
+ if (showPnl) {
+ items.push(kpiItem("浮盈亏", pnlSigned(floating, 2), pnlClass(floating)));
+ }
elKpi.innerHTML = `
${items.join("")}
`;
}
@@ -197,6 +209,7 @@
function renderUnifiedPerpTable(rows) {
if (!rows.length) return "";
+ const showPnl = showAccountPnlPref();
const body = rows
.map(({ ac, ln }) => {
const source = String((ln && ln.source) || "—");
@@ -213,7 +226,7 @@
${contracts} |
${slTpCell(ln, "sl")} |
${slTpCell(ln, "tp")} |
- ${floatPnlCell(ln)} |
+ ${showPnl ? `${floatPnlCell(ln)} | ` : ""}
`;
})
.join("");
@@ -222,7 +235,9 @@
- | 交易所 | 类型 | 合约 | 方向 | 开仓价 | 标记价 | 张数 | 止损 | 止盈 | 浮盈 |
+ 交易所 | 类型 | 合约 | 方向 | 开仓价 | 标记价 | 张数 | 止损 | 止盈 | ${
+ showPnl ? "浮盈 | " : ""
+ }
${body}
@@ -291,7 +306,7 @@
return null;
}
- function renderOptionsLegRow(ac, p) {
+ function renderOptionsLegRow(ac, p, showPnl) {
const optType =
(p.opt_type || "").toUpperCase() === "C"
? "Call"
@@ -303,21 +318,25 @@
const targetCls = target && target !== "—" ? "dash-target-monitor is-on" : "dash-target-monitor";
const net = optionsNetPnl(p);
const roi = optionsRoiPct(p);
- return `
+ let html = `
| ${exchangeLinkCell(ac)} |
${sourceTypeCell(source)} |
${esc(shortDashInst(p.inst_id))} |
${esc(optType)} |
${dashOptionsExpiryCd(p.exp_time_ms != null ? p.exp_time_ms : p.exp_time)} |
${p.idx_px != null ? fmt(p.idx_px, 0) : "—"} |
- ${esc(target)} |
- ${net != null ? pnlSigned(net, 2) : "—"} |
- ${roi != null ? esc(Number(roi).toFixed(2)) + "%" : "—"} |
-
`;
+
${esc(target)} | `;
+ if (showPnl) {
+ html += `
${net != null ? pnlSigned(net, 2) : "—"} |
+
${roi != null ? esc(Number(roi).toFixed(2)) + "%" : "—"} | `;
+ }
+ html += "";
+ return html;
}
function renderUnifiedOptionsTable(rows) {
if (!rows.length) return "";
+ const showPnl = showAccountPnlPref();
// 同所同计划相邻,Call 在前 Put 在后;不额外画分组框
const sorted = rows.slice().sort((a, b) => {
const ka = optionsGroupKey(a.ac, a.p);
@@ -330,14 +349,16 @@
if (tb === "C") return 1;
return ta.localeCompare(tb);
});
- const body = sorted.map(({ ac, p }) => renderOptionsLegRow(ac, p)).join("");
+ const body = sorted.map(({ ac, p }) => renderOptionsLegRow(ac, p, showPnl)).join("");
return `
期权持仓
- | 交易所 | 类型 | 合约 | Call/Put | 到期倒计时 | 指数 | 目标监控 | 净盈亏 | 收益率 |
+ 交易所 | 类型 | 合约 | Call/Put | 到期倒计时 | 指数 | 目标监控 | ${
+ showPnl ? "净盈亏 | 收益率 | " : ""
+ }
${body}
@@ -539,5 +560,9 @@
inited = false;
stopLive();
},
+ refresh() {
+ if (!inited) return;
+ void fetchDashboardSnapshot({ silent: true, force: true });
+ },
};
})();
diff --git a/manual_trading_hub/static/index.html b/manual_trading_hub/static/index.html
index 75b168f..139e560 100644
--- a/manual_trading_hub/static/index.html
+++ b/manual_trading_hub/static/index.html
@@ -1212,7 +1212,7 @@