Pin market watch to held option strike while a position is open.

Stop falling back to ATM quotes for unrealized/close PnL after ATM drifts or restart.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-26 18:37:20 +08:00
parent 4994aaab16
commit 38ffbf728b
5 changed files with 184 additions and 31 deletions
+20
View File
@@ -156,6 +156,26 @@ def test_deep_otm_and_expiry_settle() -> None:
assert settled.notional == 0.0
def test_pair_from_held_option_inst() -> None:
from app.exchange.option_ids import flip_option_side, pair_from_option_inst
put = "ETH-USD_UM-260727-1880-P"
pair = pair_from_option_inst(put)
assert pair is not None
assert pair.strike == 1880
assert pair.expiry_ymd == "260727"
assert pair.put_inst_id == put
assert pair.call_inst_id == "ETH-USD_UM-260727-1880-C"
assert flip_option_side(put) == pair.call_inst_id
bn = "ETH-260727-1890-C"
bp = pair_from_option_inst(bn)
assert bp is not None
assert bp.strike == 1890
assert bp.call_inst_id == bn
assert bp.put_inst_id == "ETH-260727-1890-P"
def test_option_intrinsic_and_close_bid_floor() -> None:
from app.sim.pricing import (
option_expiry_settle,