Settle expiry options at intrinsic value like live exchange.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 16:08:44 +08:00
parent a58d97938c
commit e3671d9798
5 changed files with 109 additions and 65 deletions
+13 -2
View File
@@ -145,13 +145,24 @@ def test_expiry_close() -> None:
def test_option_intrinsic_and_close_bid_floor() -> None:
from app.sim.pricing import option_intrinsic, resolve_option_close_bid
from app.sim.pricing import (
option_expiry_settle,
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
# 到期:严格按内在价值,无滑点
settled = option_expiry_settle(intrinsic=22.0, qty_eth=2.0, fee_rate=0.0005)
assert settled.fill_px == 22.0
assert settled.slip == 0.0
assert settled.notional == 44.0
assert abs(settled.fee - 44.0 * 0.0005) < 1e-12
# 紧急垃圾买一 0.2,内在价值 22 → 抬到 22
assert (
resolve_option_close_bid(
bid=0.2, mark=0.2, intrinsic=22.0, bypass_liquidity=True