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:
@@ -1129,16 +1129,23 @@ class OkxLiveExecutor(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,
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user