币本位顶栏资金显示USDT+ETH,单笔期权本位改为下拉选择
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -3882,27 +3882,59 @@
|
||||
};
|
||||
}
|
||||
|
||||
function renderStatRow(funding, trading, upnl, kind) {
|
||||
function renderStatRow(funding, trading, upnl, kind, optMeta) {
|
||||
if (!showAccountPnlPref()) return "";
|
||||
const isOpt = kind === "options";
|
||||
const fundLabel = isOpt ? "期权资金账户" : "资金账户";
|
||||
const tradeLabel = isOpt ? "期权交易账户" : "交易账户";
|
||||
const pnlLabel = isOpt ? "期权浮盈" : "浮盈合计";
|
||||
const rowCls = isOpt ? "stat-row stat-row-options" : "stat-row";
|
||||
let fundTxt = `${fmt(funding, 2)} <small style="font-size:12px;color:var(--muted)">U</small>`;
|
||||
let tradeTxt = `${fmt(trading, 2)} <small style="font-size:12px;color:var(--muted)">U</small>`;
|
||||
if (isOpt && optMeta && (optMeta.options_margin_mode === "coin" || optMeta.margin_mode === "coin")) {
|
||||
const underly = String(optMeta.options_underly || "ETH").toUpperCase();
|
||||
fundTxt = formatCoinOptFunds(optMeta, "funding", underly);
|
||||
tradeTxt = formatCoinOptFunds(optMeta, "trading", underly);
|
||||
}
|
||||
return `<div class="${rowCls}">
|
||||
<div class="stat-box"><div class="stat-label">${fundLabel}</div><div class="stat-value">${fmt(funding, 2)} <small style="font-size:12px;color:var(--muted)">U</small></div></div>
|
||||
<div class="stat-box"><div class="stat-label">${tradeLabel}</div><div class="stat-value">${fmt(trading, 2)} <small style="font-size:12px;color:var(--muted)">U</small></div></div>
|
||||
<div class="stat-box"><div class="stat-label">${fundLabel}</div><div class="stat-value">${fundTxt}</div></div>
|
||||
<div class="stat-box"><div class="stat-label">${tradeLabel}</div><div class="stat-value">${tradeTxt}</div></div>
|
||||
<div class="stat-box"><div class="stat-label">${pnlLabel}</div><div class="stat-value ${pnlCls(upnl)}">${fmt(upnl, 2)}</div></div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function formatCoinOptFunds(opt, side, underly) {
|
||||
const bal = (opt && opt.balances) || {};
|
||||
const usdt = side === "funding"
|
||||
? (bal.funding_usdt != null ? bal.funding_usdt : opt.funding_usdt)
|
||||
: (bal.trading_usdt != null ? bal.trading_usdt : opt.trading_usdt);
|
||||
let coin = side === "funding"
|
||||
? (bal.funding_eth != null ? bal.funding_eth : bal.funding_btc)
|
||||
: (bal.trading_eth != null ? bal.trading_eth : bal.trading_btc);
|
||||
if (underly === "BTC" && side === "funding" && bal.funding_btc != null) coin = bal.funding_btc;
|
||||
if (underly === "BTC" && side === "trading" && bal.trading_btc != null) coin = bal.trading_btc;
|
||||
const parts = [];
|
||||
if (usdt != null && usdt !== "") {
|
||||
const n = Number(usdt);
|
||||
if (!Number.isNaN(n)) parts.push(`${n.toFixed(2)} USDT`);
|
||||
}
|
||||
if (coin != null && coin !== "") {
|
||||
const n = Number(coin);
|
||||
if (!Number.isNaN(n)) {
|
||||
const txt = String(n.toFixed(6)).replace(/\.?0+$/, "");
|
||||
parts.push(`${txt || "0"} ${underly}`);
|
||||
}
|
||||
}
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
}
|
||||
|
||||
function renderAccountStatRow(row, ag) {
|
||||
return renderStatRow(row.funding_usdt, row.trading_usdt, ag.total_unrealized_pnl);
|
||||
}
|
||||
|
||||
function renderOptionsAccountStatRow(opt) {
|
||||
const bal = optionsBalanceFields(opt);
|
||||
return renderStatRow(bal.funding, bal.trading, bal.upl, "options");
|
||||
return renderStatRow(bal.funding, bal.trading, bal.upl, "options", opt || {});
|
||||
}
|
||||
|
||||
function shortOptionsInst(instId) {
|
||||
|
||||
Reference in New Issue
Block a user