Align funds bar and win-rate with OO expiry intrinsic repair; wire Binance balances.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1082,6 +1082,12 @@ class OkxLiveExecutor(Matcher):
|
||||
),
|
||||
)
|
||||
now = int(time.time() * 1000)
|
||||
settle_px = None
|
||||
if reason == "expiry":
|
||||
try:
|
||||
settle_px = self._close_spot_px(get_session().snapshot())
|
||||
except Exception:
|
||||
settle_px = None
|
||||
for i, (leg, inst, qty, contracts) in enumerate(legs):
|
||||
if not inst:
|
||||
continue
|
||||
@@ -1089,6 +1095,30 @@ class OkxLiveExecutor(Matcher):
|
||||
px, fee, notional, cash = self._live_option_settlement_fill(
|
||||
option_inst_id=inst, qty_eth=qty, group_id=group_id
|
||||
)
|
||||
# 账单近零但指数已知:按内在价值对齐本地成交与入账
|
||||
if settle_px is not None and qty > 0:
|
||||
if leg == "option":
|
||||
side = str(pos.get("option_side") or "call")
|
||||
strike = self._group_strike(group_id, inst)
|
||||
else:
|
||||
side = str(pos.get("option2_side") or "put")
|
||||
try:
|
||||
strike = float(pos.get("strike2") or 0) or None
|
||||
except (TypeError, ValueError):
|
||||
strike = None
|
||||
if strike is not None:
|
||||
iv = float(
|
||||
option_intrinsic(
|
||||
option_side=side,
|
||||
strike=float(strike),
|
||||
spot=float(settle_px),
|
||||
)
|
||||
)
|
||||
tol = max(0.5, abs(iv) * 0.05)
|
||||
if abs(float(px) - iv) > tol:
|
||||
px = iv
|
||||
notional = iv * float(qty)
|
||||
cash = notional - float(fee or 0)
|
||||
else:
|
||||
px, fee, notional, cash = 0.0, 0.0, 0.0, 0.0
|
||||
if abs(cash) > 1e-12:
|
||||
@@ -1129,12 +1159,6 @@ 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=?,
|
||||
|
||||
Reference in New Issue
Block a user