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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user