Treat option-option amplitude as a maximum cap.

Reject opens when range exceeds the setting; update UI and docs labels.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-07 16:35:39 +08:00
parent 7d21bc26c7
commit eaf94448a2
9 changed files with 78 additions and 20 deletions
+46
View File
@@ -64,3 +64,49 @@ def test_compute_oo_sizing_1_1_and_reward() -> None:
def test_amplitude_range_pct() -> None:
a = AmplitudeHL(high=2030, low=1970, mid=2000, hours=12, bar_count=12)
assert abs(a.range_pct - 3.0) < 1e-9
def test_amplitude_max_gate() -> None:
from app.strategy.oo_selection import build_oo_pick_core
contracts = []
for k in (1900, 2000, 2100):
for side, letter in (("call", "C"), ("put", "P")):
contracts.append(
{
"expiry_ymd": "260810",
"expiry_ms": 1_786_320_000_000,
"strike": float(k),
"side": letter,
"inst_id": f"ETH-{k}-{letter}",
}
)
amp = AmplitudeHL(high=2030, low=1970, mid=2000, hours=12, bar_count=12)
# 3% > 上限 1.5% → 拒
assert (
build_oo_pick_core(
contracts=contracts,
spot=2000,
call_ask=5,
put_ask=5,
min_hours=1,
min_leverage=1,
amplitude_hours=12,
amplitude_pct=1.5,
amplitude=amp,
)
is None
)
# 3% ≤ 上限 3.5% → 可过振幅门(杠杆/卖一足够)
ok = build_oo_pick_core(
contracts=contracts,
spot=2000,
call_ask=5,
put_ask=5,
min_hours=1,
min_leverage=1,
amplitude_hours=12,
amplitude_pct=3.5,
amplitude=amp,
)
assert ok is not None