Hide unused risk-policy nav and options-account env for hedge-only.
Gate system-settings options panels on STANDALONE_OPTIONS_UI so settings no longer 500 without the options trading module. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+9
-1
@@ -258,7 +258,13 @@ _HEDGE_COMMON_FIELDS: list[tuple[str, str, str]] = [
|
||||
(
|
||||
"HEDGE_PLAN_BUDGET_BUFFER",
|
||||
"对冲预算缓冲比例",
|
||||
"默认 0.95;仅对冲计划;与期权页 OKX_OPTIONS_BUDGET_BUFFER 独立",
|
||||
"默认 0.95;仅对冲计划",
|
||||
),
|
||||
("OKX_OPTIONS_DEFAULT_UNDERLY", "默认标的", "如 ETH;对冲页期权链默认标的"),
|
||||
(
|
||||
"OKX_OPTIONS_CHAIN_MAX_DTE_DAYS",
|
||||
"期权链展示天数",
|
||||
"默认 14;对冲页到期日只出现该天数内的合约",
|
||||
),
|
||||
(
|
||||
"HEDGE_PLAN_MANUAL_COMPLETE_ON_PARTIAL",
|
||||
@@ -495,6 +501,8 @@ def ui_sections_for_exchange(
|
||||
if not m:
|
||||
m = _okx_mode_for_env_ui()
|
||||
sections.append(_MODE_SECTION)
|
||||
# 单独期权模式才展示「期权账户」;对冲模式相关项已并入下方对冲分区
|
||||
if m == "options":
|
||||
sections.append({"title": "期权账户", "fields": _options_fields_for_mode(m)})
|
||||
hedge_fields = _hedge_fields_for_mode(m)
|
||||
if hedge_fields:
|
||||
|
||||
@@ -17,7 +17,7 @@ DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
|
||||
# CoinOX: 已去掉交易记录与复盘 / 全站统计分析
|
||||
"show_nav_records": False,
|
||||
"show_nav_stats": False,
|
||||
"show_nav_risk_policy": True,
|
||||
"show_nav_risk_policy": False, # 本仓对冲不需要风控说明页
|
||||
"show_nav_system_guide": False,
|
||||
"show_nav_env_config": True,
|
||||
"show_nav_options": True,
|
||||
@@ -27,7 +27,7 @@ DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = {
|
||||
"show_settings_export": True,
|
||||
"show_settings_password": True,
|
||||
"show_settings_options_swap": False, # CoinOX 已移除 USDT↔USDC 兑换
|
||||
"show_settings_options_transfer": True,
|
||||
"show_settings_options_transfer": False, # 本仓不装单独期权划转 UI
|
||||
}
|
||||
|
||||
DISPLAY_LABELS: dict[str, str] = {
|
||||
@@ -86,8 +86,11 @@ def normalize_display_prefs(raw: dict | None) -> dict[str, bool]:
|
||||
out["show_nav_strategy"] = False
|
||||
out["show_nav_strategy_records"] = False
|
||||
out["show_nav_system_guide"] = False
|
||||
out["show_nav_risk_policy"] = False
|
||||
out["show_settings_options_swap"] = False
|
||||
out["show_settings_transfer"] = False
|
||||
# 本仓不装单独期权 UI:系统设置不展示期权划转/兑换(避免缺模板/缺 API 500)
|
||||
out["show_settings_options_transfer"] = False
|
||||
return out
|
||||
|
||||
|
||||
@@ -130,18 +133,15 @@ def tab_allowed(tab: str, display: Optional[dict[str, bool]] = None) -> bool:
|
||||
|
||||
|
||||
def display_meta_for_ui() -> list[dict[str, Any]]:
|
||||
# CoinOX 顶栏仅保留期权/对冲相关入口
|
||||
# CoinOX 顶栏仅保留对冲相关入口
|
||||
nav_keys = [
|
||||
"show_nav_options",
|
||||
"show_nav_options_review",
|
||||
"show_nav_hedge_plan",
|
||||
"show_nav_risk_policy",
|
||||
"show_nav_env_config",
|
||||
]
|
||||
settings_keys = [
|
||||
"show_settings_export",
|
||||
"show_settings_password",
|
||||
"show_settings_options_transfer",
|
||||
]
|
||||
return [
|
||||
{"group": "顶栏导航", "entries": [{"key": k, "label": DISPLAY_LABELS[k]} for k in nav_keys]},
|
||||
|
||||
@@ -160,7 +160,19 @@ def build_instance_settings_view(
|
||||
}
|
||||
)
|
||||
|
||||
if (exchange_key or "").strip().lower() == "okx" and _env_bool("OKX_OPTIONS_ENABLED", True):
|
||||
# 单独期权 UI 才展示「期权设置」说明;本仓对冲不装该产品面
|
||||
try:
|
||||
from lib.hedge_plan.okx_trade_mode_lib import standalone_options_ui_enabled
|
||||
|
||||
_standalone_opt = standalone_options_ui_enabled()
|
||||
except Exception:
|
||||
_standalone_opt = False
|
||||
options_settings_on = (
|
||||
(exchange_key or "").strip().lower() == "okx"
|
||||
and _standalone_opt
|
||||
and _env_bool("OKX_OPTIONS_ENABLED", True)
|
||||
)
|
||||
if options_settings_on:
|
||||
api_key = (os.getenv("OKX_API_KEY") or "").strip()
|
||||
sections.append(
|
||||
{
|
||||
@@ -193,8 +205,7 @@ def build_instance_settings_view(
|
||||
"sections": sections,
|
||||
"data_export_version": int(data_export_version),
|
||||
"show_transfer": (exchange_key or "").strip().lower() in ("gate", "binance", "okx"),
|
||||
"options_settings_enabled": (exchange_key or "").strip().lower() == "okx"
|
||||
and _env_bool("OKX_OPTIONS_ENABLED", True),
|
||||
"options_settings_enabled": options_settings_on,
|
||||
"auto_transfer_enabled": auto_transfer_on,
|
||||
"auto_transfer_bj_hour": _env_int("AUTO_TRANSFER_BJ_HOUR", 8),
|
||||
"auto_transfer_amount": _env_float("AUTO_TRANSFER_AMOUNT", 30),
|
||||
|
||||
Reference in New Issue
Block a user