Align dashboard PnL columns with monitor; add back-to-dashboard button.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-20 12:34:09 +08:00
parent eb2afb3c55
commit 3ed8dabc76
5 changed files with 58 additions and 15 deletions
+12 -12
View File
@@ -130,14 +130,16 @@
return "—";
}
function floatPctText(pnl, notional) {
const n = Number(pnl);
const notion = Number(notional);
if (!Number.isFinite(n) || !Number.isFinite(notion) || Math.abs(notion) < 1e-8) return "—";
const pct = (n / Math.abs(notion)) * 100;
const abs = Math.abs(pct).toFixed(2);
if (Math.abs(pct) < 1e-9) return "0.00%";
return `${pct > 0 ? "+" : "-"}${abs}%`;
function tpProfitCell(ln) {
const n = ln && ln.reward_at_tp_usdt != null ? Number(ln.reward_at_tp_usdt) : NaN;
if (!Number.isFinite(n)) return "—";
return `<span class="dash-tp-profit">${fmt(n, 2)}U</span>`;
}
function floatPnlCell(ln) {
const pnl = ln && ln.pnl != null ? Number(ln.pnl) : NaN;
if (!Number.isFinite(pnl)) return "—";
return `<span class="${pnlClass(pnl)}">${fmt(pnl, 2)}</span>`;
}
function collectUnifiedPositions(accounts) {
@@ -184,8 +186,6 @@
const side = esc((ln && ln.side) || "—");
const contracts =
ln && ln.contracts != null && ln.contracts !== "" ? esc(String(ln.contracts)) : "—";
const pnl = ln && ln.pnl != null ? Number(ln.pnl) : NaN;
const pct = floatPctText(pnl, ln && ln.notional_usdt);
return `<tr>
<td>${exchangeLinkCell(ac)}</td>
<td>${sourceTypeCell(source)}</td>
@@ -194,8 +194,8 @@
<td>${priceCell(ln && ln.entry_price_fmt, ln && ln.entry_price)}</td>
<td>${priceCell(ln && ln.mark_price_fmt, ln && ln.mark_price)}</td>
<td>${contracts}</td>
<td class="${pnlClass(pnl)}">${Number.isFinite(pnl) ? pnlSigned(pnl, 2) : "—"}</td>
<td class="${pnlClass(pnl)}">${pct}</td>
<td>${tpProfitCell(ln)}</td>
<td>${floatPnlCell(ln)}</td>
</tr>`;
})
.join("");