Hedge start: re-quote ask and resize OO sheets; add HEDGE_PLAN_BUDGET_BUFFER.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -133,15 +133,15 @@ class TestHedgePlanOrderPath(unittest.TestCase):
|
||||
|
||||
def test_dry_run_oo(self):
|
||||
quote = MagicMock(
|
||||
return_value={
|
||||
side_effect=lambda _ex, inst_id: {
|
||||
"ok": True,
|
||||
"ask": 10,
|
||||
"ask_sz": 5,
|
||||
"ask_sz": 50,
|
||||
"can_open": True,
|
||||
"ct_mult": 0.01,
|
||||
"tick_sz": "0.1",
|
||||
"strike": 1800,
|
||||
"meta": {"optType": "C"},
|
||||
"meta": {"optType": "C" if inst_id == "A" else "P"},
|
||||
}
|
||||
)
|
||||
cfg = {
|
||||
@@ -149,17 +149,27 @@ class TestHedgePlanOrderPath(unittest.TestCase):
|
||||
"quote_option_contract": quote,
|
||||
"place_option_limit_order": MagicMock(),
|
||||
"td_mode_for_option_buy": lambda x: "isolated",
|
||||
"trade_budget_usdc": 10,
|
||||
"budget_buffer": 0.95,
|
||||
}
|
||||
body = {
|
||||
"target_price": 1900,
|
||||
"target_price_up": 1950,
|
||||
"target_price_down": 1750,
|
||||
"leg_a": {"inst_id": "A", "sheets": 1},
|
||||
"leg_b": {"inst_id": "B", "sheets": 1},
|
||||
"oo_sheets_mode": "same_sheets",
|
||||
"leg_a": {"inst_id": "A", "sheets": 1, "opt_type": "C"},
|
||||
"leg_b": {"inst_id": "B", "sheets": 1, "opt_type": "P"},
|
||||
}
|
||||
out = execute_options_options_start(cfg, body, dry_run=True)
|
||||
self.assertTrue(out["ok"])
|
||||
from unittest import mock
|
||||
|
||||
with mock.patch(
|
||||
"lib.exchange.okx_options_lib.fetch_options_trading_usdc",
|
||||
return_value=100.0,
|
||||
):
|
||||
out = execute_options_options_start(cfg, body, dry_run=True)
|
||||
self.assertTrue(out["ok"], out)
|
||||
self.assertEqual(len(out["results"]), 2)
|
||||
self.assertTrue(out.get("refresh", {}).get("ok"))
|
||||
|
||||
def test_buy_rejects_without_ask_depth(self):
|
||||
from lib.hedge_plan.hedge_plan_orders_lib import _buy_option
|
||||
|
||||
Reference in New Issue
Block a user