Split OO budget per leg and size Call/Put independently.

Each half of the risk budget buys its own qty from ask; equal qty no longer forced.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-07 17:08:05 +08:00
parent 24943adf13
commit 24a860ad3f
11 changed files with 210 additions and 110 deletions
+22 -1
View File
@@ -46,6 +46,25 @@ def test_select_oo_pair_same_expiry(tmp_path=None) -> None:
def test_compute_oo_sizing_1_1_and_reward() -> None:
r = compute_oo_sizing(
budget=100.0,
call_ask=5.0,
put_ask=10.0, # Put 更贵 → 数量更少
fee_rate=0.0,
index_px=2000.0,
cushion=1.0, # 测纯平分,不预留
reward_ratio=2.0,
)
assert r.ok
# 各 50UCall 50/5=10Put 50/10=5
assert r.call_qty_eth == 10.0
assert r.put_qty_eth == 5.0
assert abs(float(r.net_profit_target or 0) - 200.0) < 1e-9
assert abs(float(r.call_premium or 0) - 50.0) < 1e-6
assert abs(float(r.put_premium or 0) - 50.0) < 1e-6
def test_compute_oo_sizing_equal_asks() -> None:
r = compute_oo_sizing(
budget=100.0,
call_ask=5.0,
@@ -56,7 +75,9 @@ def test_compute_oo_sizing_1_1_and_reward() -> None:
reward_ratio=2.0,
)
assert r.ok
assert r.qty_eth == 9.2
# 各腿 46U / 5 = 9.2
assert r.call_qty_eth == 9.2
assert r.put_qty_eth == 9.2
assert abs(float(r.net_profit_target or 0) - 200.0) < 1e-9
assert float(r.call_premium or 0) + float(r.put_premium or 0) <= 92.0 + 1e-6