Enable options by default and allow full sim trading without OKX API keys.

Relax hedge start gates in sim, route perp open/close through sim broker, and mount strategy templates for records pages.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-14 09:26:38 +08:00
parent d4b970cfd5
commit b4d62ea0a6
8 changed files with 445 additions and 352 deletions
+11 -1
View File
@@ -93,7 +93,7 @@ def _build_cfg(app_module: Any) -> dict[str, Any]:
"alt_leverage": int(getattr(app_module, "ALT_LEVERAGE", 5) or 5),
"full_margin_buffer": float(getattr(app_module, "FULL_MARGIN_BUFFER_RATIO", 0.98) or 0.98),
"funds_decimals": int(getattr(app_module, "FUNDS_DECIMALS", 2) or 2),
"options_enabled": _env_bool("OKX_OPTIONS_ENABLED", False),
"options_enabled": _env_bool("OKX_OPTIONS_ENABLED", True),
"default_underly": (os.getenv("OKX_OPTIONS_DEFAULT_UNDERLY") or "ETH").strip().upper(),
"chain_max_dte": float(os.getenv("OKX_OPTIONS_CHAIN_MAX_DTE_DAYS") or os.getenv("OKX_OPTIONS_MAX_DTE_DAYS") or "14"),
"perp_account_label": (os.getenv("OKX_ACCOUNT_LABEL") or "合约账户").strip(),
@@ -195,6 +195,15 @@ def _gates_dict(cfg: dict[str, Any], plan_type: str) -> dict[str, Any]:
# fail-closed:探测失败视为不可开仓
active = 10**9
has_standalone = True
sim_mode = False
try:
from lib.sim.mode_lib import is_sim_mode
get_db = cfg.get("get_db")
if callable(get_db):
sim_mode = bool(is_sim_mode(get_db))
except Exception:
sim_mode = False
return gate_status(
hedge_enabled=_hedge_enabled(),
sizing_mode=load_position_sizing_mode(),
@@ -208,6 +217,7 @@ def _gates_dict(cfg: dict[str, Any], plan_type: str) -> dict[str, Any]:
show_options_options=_show_options_options(),
mutual_exclusive=mutual,
has_standalone_option=has_standalone,
sim_mode=sim_mode,
)