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
@@ -1082,16 +1082,23 @@ class BinanceLiveExecutor(Matcher):
)
summary = summarize_fills_pnl(list(fill_rows))
net = float(summary.get("net_pnl") or 0.0)
settle_px = None
if reason == "expiry":
try:
settle_px = self._close_spot_px(get_session().snapshot())
except Exception:
settle_px = None
with self.db._lock:
self.db._conn.execute(
"""UPDATE groups SET status=?, close_at_ms=?, close_reason=?, realized_pnl=?,
note=? WHERE group_id=?""",
note=?, settle_index_px=COALESCE(?, settle_index_px) WHERE group_id=?""",
(
"closed",
int(time.time() * 1000),
reason,
net,
f"oo full close {reason} exchange_flat_or_settle",
float(settle_px) if settle_px is not None else None,
group_id,
),
)