Floor option close at intrinsic to fix expiry garbage quotes.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -142,3 +142,40 @@ def test_expiry_close() -> None:
|
||||
assert d2.reason == "expiry"
|
||||
d3 = check_expiry_close(expiry_ms=1_000, now_ms=1_001)
|
||||
assert d3.should_close is True
|
||||
|
||||
|
||||
def test_option_intrinsic_and_close_bid_floor() -> None:
|
||||
from app.sim.pricing import option_intrinsic, resolve_option_close_bid
|
||||
|
||||
assert option_intrinsic(option_side="call", strike=1860, spot=1882) == 22.0
|
||||
assert option_intrinsic(option_side="put", strike=1860, spot=1882) == 0.0
|
||||
assert option_intrinsic(option_side="put", strike=1860, spot=1840) == 20.0
|
||||
|
||||
# 到期垃圾买一 0.2,内在价值 22 → 抬到 22
|
||||
assert (
|
||||
resolve_option_close_bid(
|
||||
bid=0.2, mark=0.2, intrinsic=22.0, bypass_liquidity=True
|
||||
)
|
||||
== 22.0
|
||||
)
|
||||
# 常规也有内在价值地板
|
||||
assert (
|
||||
resolve_option_close_bid(
|
||||
bid=0.2, mark=0.2, intrinsic=22.0, bypass_liquidity=False
|
||||
)
|
||||
== 22.0
|
||||
)
|
||||
# 买一高于内在价值,保留买一
|
||||
assert (
|
||||
resolve_option_close_bid(
|
||||
bid=25.0, mark=24.0, intrinsic=22.0, bypass_liquidity=True
|
||||
)
|
||||
== 25.0
|
||||
)
|
||||
# bypass 无买一,用标记与内在价值
|
||||
assert (
|
||||
resolve_option_close_bid(
|
||||
bid=None, mark=3.0, intrinsic=22.0, bypass_liquidity=True
|
||||
)
|
||||
== 22.0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user