feat(hub): show funding, trading account and unrealized PnL on monitor cards
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -854,7 +854,11 @@
|
||||
const pos = Array.isArray(ag.positions) ? ag.positions : [];
|
||||
const flaskOk = row.flask_ok !== false && hm.ok !== false;
|
||||
const upnl = Number(ag.total_unrealized_pnl);
|
||||
const balance = Number(ag.balance_usdt);
|
||||
const tradingBal = Number(row.trading_usdt);
|
||||
const balance =
|
||||
Number.isFinite(tradingBal) && tradingBal > 0
|
||||
? tradingBal
|
||||
: Number(ag.balance_usdt);
|
||||
const sortUpnl = Number.isFinite(upnl) ? upnl : 0;
|
||||
|
||||
if (!row.http_ok) {
|
||||
@@ -2298,12 +2302,18 @@
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderAccountStatRow(row, ag) {
|
||||
const upnl = ag.total_unrealized_pnl;
|
||||
return `<div class="stat-row">
|
||||
<div class="stat-box"><div class="stat-label">资金账户</div><div class="stat-value">${fmt(row.funding_usdt, 2)} <small style="font-size:12px;color:var(--muted)">U</small></div></div>
|
||||
<div class="stat-box"><div class="stat-label">交易账户</div><div class="stat-value">${fmt(row.trading_usdt, 2)} <small style="font-size:12px;color:var(--muted)">U</small></div></div>
|
||||
<div class="stat-box"><div class="stat-label">浮盈合计</div><div class="stat-value ${pnlCls(upnl)}">${fmt(upnl, 2)}</div></div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderGridBody(row, ag, pos, hm, flaskOk, keys, orders, trends, rolls, kmap) {
|
||||
const tickMap = buildPriceTickMap(row);
|
||||
let inner = `<div class="stat-row">
|
||||
<div class="stat-box"><div class="stat-label">余额</div><div class="stat-value">${fmt(ag.balance_usdt, 2)} <small style="font-size:12px;color:var(--muted)">U</small></div></div>
|
||||
<div class="stat-box"><div class="stat-label">浮盈合计</div><div class="stat-value ${pnlCls(ag.total_unrealized_pnl)}">${fmt(ag.total_unrealized_pnl, 2)}</div></div>
|
||||
</div>`;
|
||||
let inner = renderAccountStatRow(row, ag);
|
||||
inner += `<div class="section-title">交易所持仓 · ${pos.length} 仓</div>`;
|
||||
if (pos.length) {
|
||||
inner += renderGridPositionsTable(
|
||||
@@ -2353,10 +2363,7 @@
|
||||
html += `<div class="err">${esc(row.error || ag.error || "子代理不可用")}</div>`;
|
||||
return html;
|
||||
}
|
||||
html += `<div class="stat-row">
|
||||
<div class="stat-box"><div class="stat-label">余额</div><div class="stat-value">${fmt(ag.balance_usdt, 2)} U</div></div>
|
||||
<div class="stat-box"><div class="stat-label">浮盈合计</div><div class="stat-value ${pnlCls(ag.total_unrealized_pnl)}">${fmt(ag.total_unrealized_pnl, 2)}</div></div>
|
||||
</div>`;
|
||||
html += renderAccountStatRow(row, ag);
|
||||
const posCount = pos.length;
|
||||
const posListCls = hubPosListCountClass(posCount);
|
||||
html += `<div class="section-title">持仓(${posCount} 仓 · 每币种一卡)</div>`;
|
||||
|
||||
Reference in New Issue
Block a user