Fix OO expiry settle index: persist spot and never invent strike from OTM fill.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-11 16:44:56 +08:00
parent 4a5d19e30f
commit 3264dd4381
6 changed files with 124 additions and 17 deletions
+8 -1
View File
@@ -1000,9 +1000,15 @@ class Matcher:
now += 1
with self.db._lock:
settle_px = None
if reason == "expiry":
try:
settle_px = self._close_spot_px(get_session().snapshot())
except Exception:
settle_px = None
self.db._conn.execute(
"""UPDATE groups SET status=?, close_at_ms=?, close_reason=?, realized_pnl=?,
fees=COALESCE(fees,0)+?, note=?
fees=COALESCE(fees,0)+?, note=?, settle_index_px=COALESCE(?, settle_index_px)
WHERE group_id=?""",
(
"closed",
@@ -1011,6 +1017,7 @@ class Matcher:
float(total_pnl),
float(total_fees),
f"oo full close {reason}",
float(settle_px) if settle_px is not None else None,
group_id,
),
)