Show hub fullscreen options positions as cards matching instance data.

Enrich hub options snapshot with close preview and render read-only option position cards in exchange fullscreen view.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-11 09:40:35 +08:00
parent baf94b4feb
commit 843d87422d
8 changed files with 292 additions and 23 deletions
+8 -15
View File
@@ -216,22 +216,15 @@ def _attach_close_preview(
sheets: int | None = None,
premium_paid: float | None = None,
) -> dict[str, Any]:
inst_id = str(row.get("inst_id") or row.get("instId") or "").strip()
if not inst_id:
return row
ct_mult = float(row.get("ct_mult") or 0.01)
target_sheets = int(sheets) if sheets is not None else int(abs(_safe_float(row.get("pos")) or 0))
paid = premium_paid if premium_paid is not None else _safe_float(row.get("premium_paid"))
book = cfg["fetch_option_book_depth"](ex, inst_id, 5)
row["bid_depth"] = book.get("bids") or []
row["ask_depth"] = book.get("asks") or []
row["close_preview"] = estimate_close_by_bids(
row["bid_depth"],
target_sheets,
ct_mult=ct_mult,
premium_paid=paid,
from lib.options.options_positions_lib import attach_close_preview
return attach_close_preview(
cfg,
ex,
row,
sheets=sheets,
premium_paid=premium_paid,
)
return row
_OPTIONS_SYNC_LOCK = threading.Lock()