修复实例顶栏实时盈亏二次折算:币本位 options 浮盈已是 U,前端不再乘指数。

约 +4.3U 被当成 ETH 再 ×2700 显示成 +1.1万U;顶栏改为直接按 U 展示/与永续相加。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-09-30 22:35:53 +08:00
parent d2d431e4c9
commit 232e5e4b92
2 changed files with 12 additions and 19 deletions
+6 -10
View File
@@ -1642,19 +1642,15 @@ function paintRealtimePnlFromSnapshot(data){
const spotPx = data.options_index_px != null ? Number(data.options_index_px) : null;
if (coinMode) {
if (opt != null && !Number.isNaN(Number(opt))) {
// 币本位期权盈亏单位为币,勿与永续 U 混加成「xxU」
// options_unrealized_pnl 已是 USDT(后端按指数折算),勿再 × 指数
if (perp != null && Math.abs(Number(perp)) >= 0.005) {
// 顶栏只显示合计 U:永续 U + 期权币盈亏×指数
let totalU = Number(perp);
if (Number.isFinite(spotPx) && spotPx > 0) {
totalU += Number(opt) * spotPx;
}
const totalU = Number(perp) + Number(opt);
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;
lastRealtimePnlUnit = "U";
lastRealtimePnlSpotPx = null;
document.querySelectorAll('[data-funds-field="realtime-pnl"]').forEach((pnlEl) => {
pnlEl.innerText = text;
pnlEl.classList.toggle("pnl-pos", totalU > 0);
@@ -1662,11 +1658,11 @@ function paintRealtimePnlFromSnapshot(data){
});
return;
}
paintRealtimePnl(opt, underly, spotPx);
paintRealtimePnl(opt, "U");
return;
}
// 期权盈亏拉取失败时保留上次有效值,避免顶栏闪成 0/—
if (lastRealtimePnl != null && (lastRealtimePnlUnit === "ETH" || lastRealtimePnlUnit === "BTC")) {
if (lastRealtimePnl != null && lastRealtimePnlUnit === "U") {
return;
}
}