Count exit fees in live/SIM net PnL as entry fee x2.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-01 09:27:41 +08:00
parent dffcc4eeb9
commit 22c42a19a0
3 changed files with 20 additions and 28 deletions
+10 -3
View File
@@ -1055,9 +1055,7 @@ class Matcher:
if opt_mark is not None:
option_upl = float(opt_mark) * opt_qty - initial_premium
est_close_fees = est_perp_close_fee + est_opt_close_fee
# 净盈利:永续浮盈 + 期权浮盈 − 预估平仓手续费
net_pnl = perp_upl + option_upl - est_close_fees
book_close_fees = est_perp_close_fee + est_opt_close_fee
entry_idx = float(pos["entry_index_px"] or 0)
move = abs(float(index_px) - entry_idx) if index_px is not None and entry_idx else 0.0
@@ -1081,6 +1079,14 @@ class Matcher:
strike = float(g["strike"]) if g and g["strike"] is not None else None
expiry_ymd = str(g["expiry_ymd"]) if g and g["expiry_ymd"] else None
open_at_ms = int(g["open_at_ms"]) if g and g["open_at_ms"] else None
open_fees = abs(float(g["fees"] or 0)) if g else 0.0
# 净盈利:浮盈 − 入场手续费×2(离场费按入场估算);无入场费时退回盘口估平仓费
if open_fees > 1e-12:
est_close_fees = open_fees
net_pnl = perp_upl + option_upl - open_fees * 2.0
else:
est_close_fees = book_close_fees
net_pnl = perp_upl + option_upl - est_close_fees
expiry_ms = None
if expiry_ymd and len(expiry_ymd) == 6:
try:
@@ -1120,6 +1126,7 @@ class Matcher:
"expiry_ms": expiry_ms,
"perp_upl": perp_upl,
"option_upl": option_upl,
"fees_paid": open_fees,
"est_close_fees": est_close_fees,
"net_pnl": net_pnl,
"index_px": index_px,