币本位盈亏双显ETH/U(按指数换算);平仓卖币改为卖光交易户可用余额
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -51,14 +51,20 @@
|
||||
return "USDC";
|
||||
}
|
||||
|
||||
function pnlSignedOpt(v, ccy) {
|
||||
function pnlSignedOpt(v, ccy, spotPx) {
|
||||
const n = Number(v);
|
||||
if (!Number.isFinite(n)) return "—";
|
||||
const unit = String(ccy || "USDC").toUpperCase();
|
||||
if (unit === "ETH" || unit === "BTC") {
|
||||
const abs = Math.abs(n).toFixed(8).replace(/\.?0+$/, "") || "0";
|
||||
const sign = n > 0 ? "+" : n < 0 ? "-" : "";
|
||||
return `${sign}${abs} ${unit}`;
|
||||
const coinTxt = `${sign}${abs} ${unit}`;
|
||||
const px = Number(spotPx);
|
||||
if (!Number.isFinite(px) || !(px > 0)) return coinTxt;
|
||||
const u = n * px;
|
||||
const uAbs = Math.abs(u).toFixed(2);
|
||||
const uSign = u < 0 ? "-" : u > 0 ? "+" : "";
|
||||
return `${coinTxt} / ${uSign}${uAbs}U`;
|
||||
}
|
||||
return pnlSigned(n, 2);
|
||||
}
|
||||
@@ -361,7 +367,15 @@
|
||||
<td>${p.idx_px != null ? fmt(p.idx_px, 0) : "—"}</td>
|
||||
<td><span class="${targetCls}">${esc(target)}</span></td>`;
|
||||
if (showPnl) {
|
||||
html += `<td class="${pnlClass(net)}">${net != null ? pnlSignedOpt(net, optPremiumCcyOf(p)) : "—"}</td>
|
||||
html += `<td class="${pnlClass(net)}">${
|
||||
net != null
|
||||
? pnlSignedOpt(
|
||||
net,
|
||||
optPremiumCcyOf(p),
|
||||
Number(p.idx_px != null ? p.idx_px : p.idxPx) || null
|
||||
)
|
||||
: "—"
|
||||
}</td>
|
||||
<td class="${pnlClass(roi)}">${roi != null ? esc(Number(roi).toFixed(2)) + "%" : "—"}</td>`;
|
||||
}
|
||||
html += "</tr>";
|
||||
|
||||
Reference in New Issue
Block a user