Add HEDGE_PO_MODE instance modes with shared sim/live path.
Lock one mode per instance/subaccount, cross-asset BTC option/ETH perp sizing, combo-U exit, and ship docs/tests/audit. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
"""永期「以期权为主」定仓/方向/目标位/校验."""
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from lib.hedge_plan.hedge_plan_option_primary_lib import (
|
||||
PREMIUM_EXEC_FACTOR,
|
||||
@@ -114,6 +116,7 @@ class TestOptionPrimary(unittest.TestCase):
|
||||
body = {
|
||||
"option_primary": True,
|
||||
"watch_entry": 0,
|
||||
"market_order": 1,
|
||||
"direction": "long",
|
||||
"contracts": 1,
|
||||
"opt_inst_id": "ETH-USD-260831-1900-C",
|
||||
@@ -121,6 +124,8 @@ class TestOptionPrimary(unittest.TestCase):
|
||||
"sheets": 2,
|
||||
"exchange_symbol": "ETH/USDT:USDT",
|
||||
"premium_budget": 100,
|
||||
"exit_mode": "profit",
|
||||
"profit_target_usdt": 20,
|
||||
"option_target_points": 50,
|
||||
"perp_target_points": 30,
|
||||
"option_perp_ratio": 2,
|
||||
@@ -132,11 +137,16 @@ class TestOptionPrimary(unittest.TestCase):
|
||||
"min_option_hours": 36,
|
||||
"hours_to_expiry": 40,
|
||||
"option_leverage": 100,
|
||||
"underlying": "ETH",
|
||||
}
|
||||
self.assertIsNone(validate_option_primary_start(body))
|
||||
self.assertIsNone(validate_start_body("perp_options", body))
|
||||
bad = dict(body, opt_type="P")
|
||||
self.assertIsNotNone(validate_start_body("perp_options", bad))
|
||||
with patch.dict(os.environ, {"HEDGE_PO_MODE": "eth"}, clear=False):
|
||||
from lib.hedge_plan.hedge_po_mode_lib import clamp_hedge_po_mode_on_startup
|
||||
|
||||
clamp_hedge_po_mode_on_startup()
|
||||
self.assertIsNone(validate_start_body("perp_options", body))
|
||||
bad = dict(body, opt_type="P")
|
||||
self.assertIsNotNone(validate_start_body("perp_options", bad))
|
||||
|
||||
def test_pick_candidate_respects_leverage(self):
|
||||
chain = {
|
||||
|
||||
Reference in New Issue
Block a user