Sell residual options at latest bid via IOC limit, not market.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-02 14:25:03 +08:00
parent 62c91d4bd0
commit 640ecc9530
7 changed files with 89 additions and 13 deletions
+12 -4
View File
@@ -1150,7 +1150,7 @@ class BinanceLiveExecutor(Matcher):
)
def try_close_one_residual(self, row: dict) -> dict | None:
"""LIVE-BN:权利金达标后交易所市价卖出归档期权。"""
"""LIVE-BN:权利金达标后按最新买一 IOC 限价卖出归档期权(不扫市价)"""
err = self._guard_live()
if err:
logger.warning("residual premium close blocked: %s", err)
@@ -1175,17 +1175,25 @@ class BinanceLiveExecutor(Matcher):
"residual premium close skip %s: bad contracts", row.get("group_id")
)
return None
oq2 = self._quote_held_option(option_inst_id)
bid_px = float(oq2.bid) if oq2 is not None and oq2.bid is not None else float(close_bid)
if bid_px <= 0:
logger.debug(
"residual premium close skip %s: bid vanished", row.get("group_id")
)
return None
client = self._client()
try:
opt_live = client.place_option_market(
opt_live = client.place_option_ioc(
symbol=option_inst_id,
side="SELL",
quantity=max(1.0, opt_contracts),
price=bid_px,
reduce_only=True,
)
except Exception as e:
logger.warning(
"residual premium close exchange sell failed %s: %s",
"residual premium close bid-ioc sell failed %s: %s",
row.get("group_id"),
e,
)
@@ -1208,7 +1216,7 @@ class BinanceLiveExecutor(Matcher):
notional=of_notional,
slip=0.0,
now_ms=now_ms,
note="LIVE-BN residual mid-close by premium recovery",
note=f"LIVE-BN residual mid-close at bid IOC px={bid_px}",
exec_mode="LIVE",
)