Block option auto-close on stub bids far below mark.

Reject target and depth closes when bid is a residual tick, and show invalid-bid UI instead of recycling at junk prices.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-15 21:05:54 +08:00
parent e15eca76f3
commit c025c06fac
7 changed files with 387 additions and 21 deletions
+9 -1
View File
@@ -5,7 +5,7 @@ from typing import Any
from lib.options.options_db import init_options_tables
from lib.options.options_history_lib import enrich_position_row_display
from lib.options.options_pricing_lib import estimate_close_by_bids
from lib.options.options_pricing_lib import estimate_close_by_bids, intrinsic_px_per_unit
def _safe_float(v: Any) -> float | None:
@@ -34,11 +34,19 @@ def attach_close_preview(
book = cfg["fetch_option_book_depth"](ex, inst_id, 5)
row["bid_depth"] = book.get("bids") or []
row["ask_depth"] = book.get("asks") or []
mark_px = _safe_float(row.get("mark_px") or row.get("markPx"))
intrinsic = intrinsic_px_per_unit(
row.get("opt_type") or row.get("optType"),
_safe_float(row.get("strike") or row.get("stk")),
_safe_float(row.get("idx_px") or row.get("idxPx")),
)
row["close_preview"] = estimate_close_by_bids(
row["bid_depth"],
target_sheets,
ct_mult=ct_mult,
premium_paid=paid,
mark_px=mark_px,
intrinsic_px=intrinsic,
)
return row