单独期权增加全仓复利模式:可选上限开关,仅允许一仓
用期权户全部可用×缓冲开仓,默认不设上限;开启上限后按 env 封顶,全仓时禁止已有持仓再开。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -119,3 +119,26 @@ def option_position_limit_block_msg(
|
||||
f"请将 OKX_OPTIONS_MAX_ACTIVE_POSITIONS 设为 0(不限制)或不小于 {active + need},或先平仓"
|
||||
)
|
||||
return f"期权持仓已达上限({active}/{mx}),请先平仓后再开"
|
||||
|
||||
|
||||
def compound_full_single_position_block_msg(
|
||||
ex: Any,
|
||||
*,
|
||||
fetch_positions=None,
|
||||
) -> Optional[str]:
|
||||
"""全仓复利:账户内已有任意期权持仓则禁止再开(仅允许 1 笔)."""
|
||||
fetch = fetch_positions
|
||||
if fetch is None:
|
||||
from lib.exchange.okx_options_lib import fetch_option_positions
|
||||
|
||||
fetch = fetch_option_positions
|
||||
try:
|
||||
rows = fetch(ex)
|
||||
except Exception:
|
||||
rows = None
|
||||
if rows is None:
|
||||
return "无法获取期权持仓,全仓复利模式暂不可开仓"
|
||||
active = count_live_option_positions(rows)
|
||||
if active >= 1:
|
||||
return f"全仓复利模式仅允许同时持有 1 笔仓位(当前 {active} 笔),请先平仓"
|
||||
return None
|
||||
|
||||
Reference in New Issue
Block a user