Support dual breakout targets for options-options hedges.

Replace single S* with up/down targets across UI, preview, persist, monitor, and alerts so ranging breakouts can close the winner either way.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-14 14:32:06 +08:00
parent f6ef06f659
commit 8ecc70a61c
13 changed files with 233 additions and 53 deletions
+17 -1
View File
@@ -72,9 +72,25 @@ class TestHedgePlanCalc(unittest.TestCase):
def test_oo_expiry_loss_flag(self):
a = {"opt_type": "C", "strike": 3300, "sheets": 1, "ct_mult": 0.01, "premium_paid": 5}
b = {"opt_type": "P", "strike": 3100, "sheets": 1, "ct_mult": 0.01, "premium_paid": 5}
p = build_options_options_preview(target_price=3500, index_px=3200, leg_a=a, leg_b=b)
p = build_options_options_preview(
target_price_up=3500,
target_price_down=3000,
index_px=3200,
leg_a=a,
leg_b=b,
)
self.assertEqual(p["summary"]["premium_paid"], 10)
self.assertTrue(p["summary"]["expiry_is_loss"])
self.assertEqual(len(p["scenarios"]), 4)
self.assertEqual(p["scenarios"][0]["id"], "target_up")
self.assertEqual(p["scenarios"][1]["id"], "target_down")
def test_oo_legacy_single_target_still_works(self):
a = {"opt_type": "C", "strike": 3300, "sheets": 1, "ct_mult": 0.01, "premium_paid": 5}
b = {"opt_type": "P", "strike": 3100, "sheets": 1, "ct_mult": 0.01, "premium_paid": 5}
p = build_options_options_preview(target_price=3500, index_px=3200, leg_a=a, leg_b=b)
self.assertEqual(p["target_price_up"], 3500)
self.assertEqual(p["target_price_down"], 3500)
def test_perp_short_pnl(self):
self.assertEqual(