Fix strategy-logic P0s from audit: monitor false-flat, fill-confirmed open/close, mode gates.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -50,12 +50,28 @@ class TestHedgePlanOrderPath(unittest.TestCase):
|
||||
"tp": 1900,
|
||||
"sl": 1700,
|
||||
"contracts": 1,
|
||||
"opt_inst_id": "X",
|
||||
"opt_inst_id": "ETH-USD-260731-1800-P",
|
||||
"opt_type": "P",
|
||||
"sheets": 1,
|
||||
"exchange_symbol": "ETH/USDT:USDT",
|
||||
},
|
||||
)
|
||||
self.assertIsNone(ok)
|
||||
bad_type = validate_start_body(
|
||||
"perp_options",
|
||||
{
|
||||
"direction": "long",
|
||||
"entry": 1800,
|
||||
"tp": 1900,
|
||||
"sl": 1700,
|
||||
"contracts": 1,
|
||||
"opt_inst_id": "ETH-USD-260731-1800-C",
|
||||
"opt_type": "C",
|
||||
"sheets": 1,
|
||||
"exchange_symbol": "ETH/USDT:USDT",
|
||||
},
|
||||
)
|
||||
self.assertIsNotNone(bad_type)
|
||||
|
||||
def test_gate_can_start_when_live(self):
|
||||
g = gate_status(
|
||||
@@ -196,7 +212,7 @@ class TestHedgePlanOrderPath(unittest.TestCase):
|
||||
self.assertIn("卖一", out["msg"])
|
||||
cfg["place_option_limit_order"].assert_not_called()
|
||||
|
||||
def test_buy_caps_sheets_to_ask_depth(self):
|
||||
def test_buy_rejects_when_ask_depth_below_request(self):
|
||||
from lib.hedge_plan.hedge_plan_orders_lib import _buy_option
|
||||
|
||||
quote = MagicMock(
|
||||
@@ -217,8 +233,9 @@ class TestHedgePlanOrderPath(unittest.TestCase):
|
||||
"td_mode_for_option_buy": lambda x: "isolated",
|
||||
}
|
||||
out = _buy_option(cfg, inst_id="X", sheets=9, dry_run=True)
|
||||
self.assertTrue(out["ok"])
|
||||
self.assertEqual(out["sheets"], 2)
|
||||
self.assertFalse(out["ok"])
|
||||
self.assertIn("不足请求", out["msg"])
|
||||
cfg["place_option_limit_order"].assert_not_called()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user