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
+32
View File
@@ -221,6 +221,38 @@ def test_estimate_close_by_bids_empty():
assert out["avg_px"] is None
def test_stub_bid_blocks_auto_close_estimate():
from lib.options.options_pricing_lib import estimate_close_by_bids, is_stub_bid_px
stub, reason = is_stub_bid_px(0.2, mark_px=42.0)
assert stub is True
assert "残档" in reason or "无效" in reason or "远低于" in reason
out = estimate_close_by_bids(
[{"px": 0.2, "sz": 3500}],
66,
ct_mult=0.01,
premium_paid=9.37,
mark_px=42.0,
)
assert out["auto_close_blocked"] is True
assert out["bid_invalid"] is True
assert out["estimated_pnl"] is None
assert out["levels"] == []
ok, _ = is_stub_bid_px(30.0, mark_px=42.0)
assert ok is False
good = estimate_close_by_bids(
[{"px": 30.0, "sz": 100}],
10,
ct_mult=0.01,
premium_paid=1.0,
mark_px=42.0,
)
assert good["auto_close_blocked"] is False
assert good["covered_sheets"] == 10
def test_expiry_breakeven_from_ask():
from lib.options.options_pricing_lib import expiry_breakeven_from_ask