Add env toggles to show/hide perp and options hedge plan tabs.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-19 00:43:04 +08:00
parent 9e1343981d
commit f21e4d1166
10 changed files with 109 additions and 6 deletions
+26
View File
@@ -69,6 +69,32 @@ class TestHedgePlanCalc(unittest.TestCase):
self.assertFalse(g["can_start"])
self.assertTrue(any("全仓" in r for r in g["reasons"]))
def test_gate_hidden_plan_type_blocks_preview(self):
g = gate_status(
hedge_enabled=True,
sizing_mode="full_margin",
plan_type="perp_options",
options_enabled=True,
live_order=True,
live_trading=True,
show_perp_options=False,
)
self.assertFalse(g["can_preview"])
self.assertFalse(g["can_start"])
self.assertTrue(any("隐藏" in r for r in g["reasons"]))
self.assertFalse(g["show_perp_options"])
self.assertTrue(g["show_options_options"])
g2 = gate_status(
hedge_enabled=True,
sizing_mode="risk",
plan_type="options_options",
options_enabled=True,
show_options_options=False,
)
self.assertFalse(g2["can_preview"])
self.assertTrue(any("期期" in r for r in g2["reasons"]))
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}