Prefer open direction from ATM vs spot (below=Call/short, above=Put/long).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:39:23 +08:00
parent ee0ec57f89
commit 79c074ec6c
6 changed files with 110 additions and 25 deletions
+25
View File
@@ -28,6 +28,31 @@ def test_signal_equal() -> None:
assert decide(10.0, 10.0) is None
def test_signal_strike_below_spot_call_short() -> None:
# 现价 1859、ATM 1850:即使 Put 卖一更高,也走 Call+空
s = decide(10.0, 20.0, strike=1850, mark_px=1859)
assert s is not None
assert s.option_side == "call"
assert s.perp_side == "short"
assert s.bias == "strike_below_spot"
def test_signal_strike_above_spot_put_long() -> None:
# 现价 1859、ATM 1875:即使 Call 卖一更高,也走 Put+多
s = decide(20.0, 10.0, strike=1875, mark_px=1859)
assert s is not None
assert s.option_side == "put"
assert s.perp_side == "long"
assert s.bias == "strike_above_spot"
def test_signal_strike_flat_falls_back_to_ask() -> None:
s = decide(20.0, 15.0, strike=1860, mark_px=1860)
assert s is not None
assert s.bias == "call_ask_gt_put"
assert s.option_side == "call"
def test_exit_fixed_and_premium_multiple() -> None:
fixed = check_exits(
net_pnl=15.0,