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:
@@ -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 = {}
|
||||
|
||||
Reference in New Issue
Block a user