Add OKX options max active positions env gate.

Enforce concurrent option contract count on standalone and hedge buys; editable in env UI with hot reload (0 = unlimited).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-30 08:12:50 +08:00
parent 644dcdf092
commit 94c65cbd6e
8 changed files with 203 additions and 0 deletions
+9
View File
@@ -125,6 +125,15 @@ def _buy_option(
"ref_ask": q.get("ref_ask"),
"can_open": False,
}
from lib.options.options_position_limit_lib import option_position_limit_block_msg
pos_limit_msg = option_position_limit_block_msg(
ex,
opening_inst_id=inst_id,
fetch_positions=cfg.get("fetch_option_positions"),
)
if pos_limit_msg:
return {"ok": False, "msg": pos_limit_msg, "quote": q, "can_open": False}
sheets_i = max(1, int(round(float(sheets))))
capped, cap_msg = cap_option_buy_sheets_to_ask_depth(sheets_i, ask_sz, min_sz=1)
if capped is None: