Reject OO strikes more than 1% from amplitude high/low.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,23 @@ def test_otm_strikes_near_amplitude() -> None:
|
||||
assert pick_otm_put_strike(strikes, spot=1950, low=1860) == 1850.0
|
||||
|
||||
|
||||
def test_otm_strikes_reject_beyond_1pct() -> None:
|
||||
# 高点 2000,最近虚值 Call 仅 2100(偏离 5%)→ 拒绝
|
||||
strikes = [1900.0, 1950.0, 2100.0]
|
||||
assert pick_otm_call_strike(strikes, spot=1950, high=2000, max_dev_pct=1.0) is None
|
||||
# 低点 1900,最近虚值 Put 仅 1800(偏离 ~5.3%)→ 拒绝
|
||||
assert (
|
||||
pick_otm_put_strike(
|
||||
[1800.0, 1950.0, 2000.0], spot=1950, low=1900, max_dev_pct=1.0
|
||||
)
|
||||
is None
|
||||
)
|
||||
# 高点 2095,Call 2100 偏离约 0.24% → 通过
|
||||
assert (
|
||||
pick_otm_call_strike(strikes, spot=1950, high=2095, max_dev_pct=1.0) == 2100.0
|
||||
)
|
||||
|
||||
|
||||
def test_select_oo_pair_same_expiry(tmp_path=None) -> None:
|
||||
contracts = []
|
||||
for k in (1900, 2000, 2100):
|
||||
@@ -36,6 +53,7 @@ def test_select_oo_pair_same_expiry(tmp_path=None) -> None:
|
||||
high=2105.0,
|
||||
low=1890.0,
|
||||
min_hours=1.0,
|
||||
max_dev_pct=1.0,
|
||||
)
|
||||
assert picked is not None
|
||||
ymd, _ems, ck, pk, call_i, put_i = picked
|
||||
@@ -114,7 +132,7 @@ def test_amplitude_max_gate() -> None:
|
||||
from app.strategy.oo_selection import build_oo_pick_core
|
||||
|
||||
contracts = []
|
||||
for k in (1900, 2000, 2100):
|
||||
for k in (1900, 1975, 2000, 2025, 2100):
|
||||
for side, letter in (("call", "C"), ("put", "P")):
|
||||
contracts.append(
|
||||
{
|
||||
@@ -141,7 +159,7 @@ def test_amplitude_max_gate() -> None:
|
||||
)
|
||||
is None
|
||||
)
|
||||
# 3% ≤ 上限 3.5% → 可过振幅门(杠杆/卖一足够)
|
||||
# 3% ≤ 上限 3.5%,且 2025/1975 贴高低 ≤1% → 通过
|
||||
ok = build_oo_pick_core(
|
||||
contracts=contracts,
|
||||
spot=2000,
|
||||
@@ -152,5 +170,8 @@ def test_amplitude_max_gate() -> None:
|
||||
amplitude_hours=12,
|
||||
amplitude_pct=3.5,
|
||||
amplitude=amp,
|
||||
max_dev_pct=1.0,
|
||||
)
|
||||
assert ok is not None
|
||||
assert ok.call.strike == 2025.0
|
||||
assert ok.put.strike == 1975.0
|
||||
|
||||
Reference in New Issue
Block a user