顶栏实时盈亏只显示U;交易账户USDT/ETH多行展示
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1093,25 +1093,27 @@ function paintRealtimePnl(v, unit, spotPx){
|
||||
}
|
||||
const sign = n > 0 ? "+" : "";
|
||||
let text;
|
||||
let tone = n;
|
||||
if (u === "ETH" || u === "BTC") {
|
||||
const abs = Math.abs(n).toFixed(8).replace(/\.?0+$/, "") || "0";
|
||||
const coinTxt = `${n < 0 ? "-" : sign}${abs} ${u}`;
|
||||
// 顶栏实时盈亏只显示 U(按指数/现货换算),不展示币数量
|
||||
const px = Number(spotPx != null ? spotPx : lastRealtimePnlSpotPx);
|
||||
if (Number.isFinite(px) && px > 0) {
|
||||
const uu = n * px;
|
||||
tone = uu;
|
||||
const uAbs = Math.abs(uu).toFixed(2);
|
||||
const uSign = uu < 0 ? "-" : uu > 0 ? "+" : "";
|
||||
text = `${coinTxt} / ${uSign}${uAbs}U`;
|
||||
text = `${uSign}${uAbs}U`;
|
||||
} else {
|
||||
text = coinTxt;
|
||||
text = "—";
|
||||
tone = 0;
|
||||
}
|
||||
} else {
|
||||
text = `${sign}${n.toFixed(2)}U`;
|
||||
}
|
||||
nodes.forEach((pnlEl) => {
|
||||
pnlEl.innerText = text;
|
||||
pnlEl.classList.toggle("pnl-pos", n > 0);
|
||||
pnlEl.classList.toggle("pnl-neg", n < 0);
|
||||
pnlEl.classList.toggle("pnl-pos", tone > 0);
|
||||
pnlEl.classList.toggle("pnl-neg", tone < 0);
|
||||
});
|
||||
}
|
||||
let lastRealtimePnl = null;
|
||||
@@ -1160,25 +1162,21 @@ function paintRealtimePnlFromSnapshot(data){
|
||||
if (coinMode) {
|
||||
if (opt != null && !Number.isNaN(Number(opt))) {
|
||||
if (perp != null && Math.abs(Number(perp)) >= 0.005) {
|
||||
const optAbs = Math.abs(Number(opt)).toFixed(8).replace(/\.?0+$/, "") || "0";
|
||||
const optSign = Number(opt) > 0 ? "+" : (Number(opt) < 0 ? "-" : "");
|
||||
const perpSign = Number(perp) > 0 ? "+" : "";
|
||||
let optPart = `${optSign}${optAbs} ${underly}`;
|
||||
// 顶栏只显示合计 U:永续 U + 期权币盈亏×指数
|
||||
let totalU = Number(perp);
|
||||
if (Number.isFinite(spotPx) && spotPx > 0) {
|
||||
const uu = Number(opt) * spotPx;
|
||||
const uAbs = Math.abs(uu).toFixed(2);
|
||||
const uSign = uu < 0 ? "-" : uu > 0 ? "+" : "";
|
||||
optPart += ` / ${uSign}${uAbs}U`;
|
||||
totalU += Number(opt) * spotPx;
|
||||
}
|
||||
const text = `${perpSign}${Number(perp).toFixed(2)}U / ${optPart}`;
|
||||
const uAbs = Math.abs(totalU).toFixed(2);
|
||||
const uSign = totalU < 0 ? "-" : totalU > 0 ? "+" : "";
|
||||
const text = `${uSign}${uAbs}U`;
|
||||
lastRealtimePnl = Number(opt);
|
||||
lastRealtimePnlUnit = underly;
|
||||
lastRealtimePnlSpotPx = spotPx;
|
||||
document.querySelectorAll('[data-funds-field="realtime-pnl"]').forEach((pnlEl) => {
|
||||
pnlEl.innerText = text;
|
||||
const n = Number(opt) + Number(perp);
|
||||
pnlEl.classList.toggle("pnl-pos", n > 0);
|
||||
pnlEl.classList.toggle("pnl-neg", n < 0);
|
||||
pnlEl.classList.toggle("pnl-pos", totalU > 0);
|
||||
pnlEl.classList.toggle("pnl-neg", totalU < 0);
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -1225,7 +1223,7 @@ function formatTradingAccountLabel(usdt, eth, btc, marginMode) {
|
||||
};
|
||||
pushCoin(eth, "ETH");
|
||||
pushCoin(btc, "BTC");
|
||||
return parts.length ? parts.join(" / ") : "—";
|
||||
return parts.length ? parts.join("\n") : "—";
|
||||
}
|
||||
|
||||
function setFundsFieldText(field, text){
|
||||
|
||||
Reference in New Issue
Block a user