diff --git a/lib/instance/templates/embed_boot_scripts.html b/lib/instance/templates/embed_boot_scripts.html index 4821929..af49498 100644 --- a/lib/instance/templates/embed_boot_scripts.html +++ b/lib/instance/templates/embed_boot_scripts.html @@ -1161,18 +1161,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))) { + // 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); @@ -1180,11 +1177,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; } } diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index 328ae89..6675cd6 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -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; } }