From e0e2a94322d4528699ddd6a39df3356f69ba01ad Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 8 Oct 2026 23:58:02 +0800 Subject: [PATCH] =?UTF-8?q?revert=E6=9C=9F=E6=9D=83=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E4=BB=8D=E6=8C=89=E5=B8=81=E5=B1=95=E7=A4=BA=E7=9B=88=E4=BA=8F?= =?UTF-8?q?=EF=BC=8CU=20=E5=8F=A3=E5=BE=84=E5=8F=AA=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E7=BB=93=E7=AE=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- lib/common/static/options_panel.js | 11 ++++------- lib/exchange/okx_options_lib.py | 15 ++------------- lib/sim/broker_lib.py | 8 +++----- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/lib/common/static/options_panel.js b/lib/common/static/options_panel.js index 073cefe..c3008cc 100644 --- a/lib/common/static/options_panel.js +++ b/lib/common/static/options_panel.js @@ -2833,15 +2833,12 @@ list.forEach(function (h) { const tr = document.createElement("tr"); const premCcy = posPremiumCcy(h); - const premUnit = premCcy === "USDC" || premCcy === "USDT" ? "U" : premCcy; - // 模拟盘盈亏已折 U 时用 pnl_display_ccy,勿再标 BTC - const pnlCcy = String(h.pnl_display_ccy || premCcy).toUpperCase(); - const pnlUnit = pnlCcy === "USDC" || pnlCcy === "USDT" ? "U" : pnlCcy; + const unit = premCcy === "USDC" ? "U" : premCcy; const premCore = fmtDisplay( h.premium_paid_fmt, h.premium_paid != null ? fmtPremiumAmt(h.premium_paid, premCcy) : null ); - const premTxt = premCore === "—" ? "—" : premCore + " " + premUnit; + const premTxt = premCore === "—" ? "—" : premCore + " " + unit; const isOpen = h.status === "open"; const pnl = isOpen ? null : h.realized_pnl; let pnlTxt = "—"; @@ -2849,9 +2846,9 @@ const n = Number(pnl); const absCore = fmtDisplay( null, - pnlUnit === "U" ? fmt(Math.abs(n), 2) : fmtPremiumAmt(Math.abs(n), pnlCcy) + fmtPremiumAmt(Math.abs(n), premCcy) ); - pnlTxt = (n > 0 ? "+" : n < 0 ? "-" : "") + absCore + " " + pnlUnit; + pnlTxt = (n > 0 ? "+" : n < 0 ? "-" : "") + absCore + " " + unit; } const pnlCls = pnl > 0 ? "pos-pnl-profit" : pnl < 0 ? "pos-pnl-loss" : ""; const timeTxt = (h.closed_at || h.created_at || "—").replace("T", " ").slice(0, 19); diff --git a/lib/exchange/okx_options_lib.py b/lib/exchange/okx_options_lib.py index 337fc7c..53992fb 100644 --- a/lib/exchange/okx_options_lib.py +++ b/lib/exchange/okx_options_lib.py @@ -1467,7 +1467,6 @@ def format_option_history_row( realized = _safe_float(raw.get("realizedPnl")) if realized is None: realized = _safe_float(raw.get("pnl")) - pnl_usdt = _safe_float(raw.get("_sim_realized_pnl_usdt")) pnl_ratio = _safe_float(raw.get("pnlRatio")) close_type = str(raw.get("type") or "").strip() utime = _safe_float(raw.get("uTime")) @@ -1478,13 +1477,6 @@ def format_option_history_row( premium_ccy = str(raw.get("_sim_premium_ccy") or "").strip().upper() or premium_ccy_for_mode( row_mode, uly or "ETH" ) - # 模拟盘已冻结 U 盈亏时,盈亏列按 U 展示(权利金仍为币) - pnl_display_ccy = str(raw.get("_sim_pnl_display_ccy") or "").strip().upper() - if pnl_usdt is not None: - realized = float(pnl_usdt) - pnl_display_ccy = "USDT" - elif not pnl_display_ccy: - pnl_display_ccy = premium_ccy if close_type in ("3", "4"): status_label = "强平" else: @@ -1513,13 +1505,10 @@ def format_option_history_row( "premium_paid": premium_paid, "premium_paid_fmt": format_premium_amount(premium_paid, ccy=premium_ccy), "premium_ccy": premium_ccy, - "pnl_display_ccy": pnl_display_ccy, "margin_mode": row_mode, "realized_pnl": realized, - "realized_pnl_usdt": pnl_usdt if pnl_usdt is not None else ( - float(realized) if pnl_display_ccy == "USDT" and realized is not None else None - ), - "realized_pnl_fmt": format_premium_amount(realized, ccy=pnl_display_ccy), + "realized_pnl_usdt": _safe_float(raw.get("_sim_realized_pnl_usdt")), + "realized_pnl_fmt": format_premium_amount(realized, ccy=premium_ccy), "pnl_ratio_pct": round(pnl_ratio * 100, 2) if pnl_ratio is not None else None, "status": "closed", "status_label": status_label, diff --git a/lib/sim/broker_lib.py b/lib/sim/broker_lib.py index 0d8de1d..0284037 100644 --- a/lib/sim/broker_lib.py +++ b/lib/sim/broker_lib.py @@ -1291,9 +1291,9 @@ class SimBroker: "closeAvgPx": str(close_px) if close_px is not None else "", "closeTotalPos": str(sheets), "openMaxPos": str(sheets), - # 展示用 U 盈亏;币数量仍放 raw 供对账 - "realizedPnl": str(round(pnl_usdt, 4)) if pnl_usdt is not None else str(round(pnl, 8)), - "pnl": str(round(pnl_usdt, 4)) if pnl_usdt is not None else str(round(pnl, 8)), + # 期权历史展示币数量盈亏;U 口径只写 _sim_realized_pnl_usdt 供统计 + "realizedPnl": str(round(pnl, 8)), + "pnl": str(round(pnl, 8)), "pnlRatio": str(round(pnl_ratio, 8)) if pnl_ratio is not None else "", "cTime": str(open_ms or ""), "uTime": str(close_ms or ""), @@ -1302,9 +1302,7 @@ class SimBroker: "stk": str(strike) if strike is not None else "", "_sim_premium_paid": paid, "_sim_premium_ccy": ccy, - "_sim_realized_pnl_coin": pnl, "_sim_realized_pnl_usdt": pnl_usdt, - "_sim_pnl_display_ccy": "USDT" if pnl_usdt is not None else ccy, } ) return out