Enable hedge-plan live opens with path validation, DB, and monitor.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -299,13 +299,17 @@ def gate_status(
|
||||
sizing_mode: str,
|
||||
plan_type: str,
|
||||
options_enabled: bool,
|
||||
live_order: bool = False,
|
||||
live_trading: bool = False,
|
||||
active_count: int = 0,
|
||||
max_active: int = 1,
|
||||
) -> dict[str, Any]:
|
||||
from lib.trade.position_sizing_lib import is_full_margin_mode
|
||||
|
||||
full = is_full_margin_mode(sizing_mode)
|
||||
pt = (plan_type or "").strip().lower()
|
||||
can_preview = True
|
||||
can_start = False
|
||||
can_start = True
|
||||
reasons: list[str] = []
|
||||
if not hedge_enabled:
|
||||
can_start = False
|
||||
@@ -314,23 +318,36 @@ def gate_status(
|
||||
can_preview = False
|
||||
can_start = False
|
||||
reasons.append("期权模块未启用")
|
||||
if not live_order:
|
||||
can_start = False
|
||||
reasons.append("未允许对冲真实下单(HEDGE_PLAN_LIVE_ORDER)")
|
||||
if active_count >= max(1, int(max_active or 1)):
|
||||
can_start = False
|
||||
reasons.append(f"活跃计划已达上限({max_active})")
|
||||
if pt == "perp_options":
|
||||
if not full:
|
||||
can_start = False
|
||||
reasons.append("永期开仓仅全仓模式可用(当前可测算)")
|
||||
elif hedge_enabled and options_enabled:
|
||||
if not live_trading:
|
||||
can_start = False
|
||||
reasons.append("P0 仅测算,真实开仓将在后续版本开放")
|
||||
reasons.append("未开启实盘(LIVE_TRADING_ENABLED)")
|
||||
elif pt == "options_options":
|
||||
if hedge_enabled and options_enabled:
|
||||
can_start = False
|
||||
reasons.append("P0 仅测算,真实开仓将在后续版本开放")
|
||||
pass
|
||||
else:
|
||||
can_start = False
|
||||
reasons.append("未知计划类型")
|
||||
if can_start:
|
||||
reasons = []
|
||||
return {
|
||||
"hedge_enabled": hedge_enabled,
|
||||
"options_enabled": options_enabled,
|
||||
"sizing_mode": sizing_mode,
|
||||
"is_full_margin": full,
|
||||
"plan_type": pt,
|
||||
"live_order": live_order,
|
||||
"live_trading": live_trading,
|
||||
"active_count": active_count,
|
||||
"max_active": max_active,
|
||||
"can_preview": can_preview,
|
||||
"can_start": can_start,
|
||||
"reasons": reasons,
|
||||
|
||||
Reference in New Issue
Block a user