Replace dashboard perp profit column with stop-loss and take-profit.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-20 12:47:16 +08:00
parent 913c7d5be6
commit f467f94fe9
4 changed files with 50 additions and 12 deletions
+16 -8
View File
@@ -130,18 +130,25 @@
return "—";
}
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 slTpCell(ln, kind) {
if (kind === "tp") {
const note = String((ln && ln.tp_note) || "").trim();
if (note) return `<span class="dash-tp-program">${esc(note)}</span>`;
}
const raw = kind === "sl" ? ln && ln.stop_loss : ln && ln.take_profit;
if (raw == null || raw === "") return "—";
if (Number.isFinite(Number(raw))) {
return esc(fmt(raw, 4).replace(/\.?0+$/, ""));
}
return esc(String(raw));
}
function collectUnifiedPositions(accounts) {
const perp = [];
const options = [];
@@ -204,7 +211,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>${tpProfitCell(ln)}</td>
<td>${slTpCell(ln, "sl")}</td>
<td>${slTpCell(ln, "tp")}</td>
<td>${floatPnlCell(ln)}</td>
</tr>`;
})
@@ -214,7 +222,7 @@
<div class="dash-table-wrap">
<table class="dash-table dash-pos-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><th>张数</th><th>止损</th><th>止盈</th><th>浮盈</th>
</tr></thead>
<tbody>${body}</tbody>
</table>