Extend semi-auto with ITM/ATM/OTM, offset, and 1:4 sizing.
Moneyness and perp:option units are plan-only; OTM enforces leverage >=180. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,7 +2,13 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.strategy.semi_auto import REASON_PERP_NET, REASON_POINTS, check_semi_exits
|
||||
from app.strategy.selection import pick_otm_strike
|
||||
from app.strategy.semi_auto import (
|
||||
REASON_PERP_NET,
|
||||
REASON_POINTS,
|
||||
check_semi_exits,
|
||||
effective_min_leverage,
|
||||
)
|
||||
|
||||
|
||||
def test_semi_points_long_needs_net_positive() -> None:
|
||||
@@ -73,3 +79,22 @@ def test_semi_not_yet() -> None:
|
||||
risk_k=1,
|
||||
)
|
||||
assert d.should_close is False
|
||||
|
||||
|
||||
def test_otm_leverage_floor() -> None:
|
||||
assert effective_min_leverage("otm", 100) == 180
|
||||
assert effective_min_leverage("otm", 200) == 200
|
||||
assert effective_min_leverage("itm", 100) == 100
|
||||
|
||||
|
||||
def test_pick_otm_within_offset() -> None:
|
||||
strikes = [1800.0, 1825.0, 1850.0, 1875.0]
|
||||
# Call 虚值:标的 1830 → 1850(20点)在 25 内;1875 超
|
||||
k = pick_otm_strike(strikes, 1830, option_side="call", max_offset=25)
|
||||
assert k == 1850.0
|
||||
assert (
|
||||
pick_otm_strike(strikes, 1830, option_side="call", max_offset=15) is None
|
||||
)
|
||||
# Put 虚值
|
||||
k2 = pick_otm_strike(strikes, 1830, option_side="put", max_offset=30)
|
||||
assert k2 == 1825.0
|
||||
|
||||
Reference in New Issue
Block a user