Fix OKX abandon residual double-book and fill/residual ledger holes.

After dual-close leaves option pending, continue close_group instead of false residual; reject partial fills on wait timeout; LIVE residual settle allow_negative.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 20:20:36 +08:00
parent ec87cf2104
commit 44fd0371b9
7 changed files with 71 additions and 44 deletions
+4
View File
@@ -854,11 +854,15 @@ class Matcher:
opt_qty = float(row["option_qty_eth"])
opt_pnl = (of.fill_px - opt_entry) * opt_qty
opt_cash = of.notional - of.fee
from ..config import get_settings
self.ledger.apply_cash(
opt_cash,
kind="close_option",
group_id=group_id,
note=f"residual option expiry settle{' force' if force else ''}",
# LIVE 本地账本仅镜像;拒记会导致 residual 永久 pending
allow_negative=not get_settings().is_sim,
)
with self.db._lock: