Fix OO expiry Put PnL: overlay wrong near-zero settlement fills with intrinsic.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-11 17:02:44 +08:00
parent 77d2effb6d
commit 3520fc0214
4 changed files with 99 additions and 18 deletions
+4 -2
View File
@@ -86,14 +86,16 @@ if REPAIR_FILLS:
).fetchone()
if not row:
continue
if abs(float(row["fill_px"] or 0)) > 1e-9:
old_px = float(row["fill_px"] or 0)
tol = max(0.5, abs(iv) * 0.05)
if abs(old_px - iv) <= tol:
continue
qty = float(row["qty_eth"] or 0)
con.execute(
"UPDATE fills SET base_px=?, fill_px=?, notional=?, slip=0 WHERE id=?",
(iv, iv, iv * qty, row["id"]),
)
updated.append((leg, iv, qty))
updated.append((leg, old_px, iv, qty))
# 重算 realized
fills = list(con.execute("SELECT * FROM fills WHERE group_id=?", (GROUP,)))
opt = {}