From 88d460d484121220eb6a1f97a2843aad041dcb2f Mon Sep 17 00:00:00 2001 From: dekun Date: Mon, 20 Jul 2026 08:46:02 +0800 Subject: [PATCH] Options: collapse open rules; move open-guard tip into risk policy. Co-authored-by: Cursor --- crypto_monitor_okx/app.py | 1 + lib/common/static/instance_theme.css | 7 ++++++- lib/env/env_ui_manifest.py | 6 +++++- lib/instance/instance_settings_lib.py | 12 ++++++++++++ lib/instance/templates/embed_shell.html | 2 +- lib/instance/templates/index.html | 2 +- lib/instance/templates/instance_top_bar.html | 13 +------------ lib/options/templates/options_panel.html | 19 ++++++++++++++++--- 8 files changed, 43 insertions(+), 19 deletions(-) diff --git a/crypto_monitor_okx/app.py b/crypto_monitor_okx/app.py index f3ec0f8..757ce21 100644 --- a/crypto_monitor_okx/app.py +++ b/crypto_monitor_okx/app.py @@ -6816,6 +6816,7 @@ def render_main_page(page="trade", embed_mode=None): risk_status=risk_status, trade_policy=TRADE_POLICY, data_export_version=3, + open_guard_enabled=open_guard_enabled, ), **force_close_template_context( FORCE_CLOSE_ENABLED, diff --git a/lib/common/static/instance_theme.css b/lib/common/static/instance_theme.css index 1405532..f1f538f 100644 --- a/lib/common/static/instance_theme.css +++ b/lib/common/static/instance_theme.css @@ -4791,14 +4791,19 @@ html[data-theme="light"] .opt-source-badge--oo { font-weight: 700; font-variant-numeric: tabular-nums; } -.options-page-wrap .opt-close-rule { +.options-page-wrap .opt-close-rule, +.options-page-wrap .opt-open-rule { margin-top: 8px; + margin-bottom: 10px; padding: 0; border: 1px solid rgba(67, 82, 118, 0.55); border-radius: 10px; background: rgba(14, 19, 30, 0.58); overflow: hidden; } +.options-page-wrap .opt-open-rule { + margin-top: 4px; +} .options-page-wrap .opt-close-rule summary { display: flex; align-items: center; diff --git a/lib/env/env_ui_manifest.py b/lib/env/env_ui_manifest.py index c75473f..378869d 100644 --- a/lib/env/env_ui_manifest.py +++ b/lib/env/env_ui_manifest.py @@ -67,7 +67,11 @@ _SHARED_SECTIONS: list[dict[str, Any]] = [ ("TRADE_SYMBOL_RESTRICT_ENABLED", "币种白名单开关", ""), ("TRADE_SYMBOL_WHITELIST", "白名单币种", "逗号分隔,如 BTC,ETH"), ("TRADING_DAY_RESET_HOUR", "交易日切点(北京时间)", "整点,默认 8"), - ("TRADING_DAY_RESET_OPEN_GUARD_ENABLED", "切点前禁止新开仓", ""), + ( + "TRADING_DAY_RESET_OPEN_GUARD_ENABLED", + "切点前禁止新开仓", + "默认 true;开启则北京时间切点前禁止斐波登记与人工开仓;说明见风控说明·交易执行", + ), ("MAX_ACTIVE_POSITIONS", "最大同时持仓", ""), ("MANUAL_MIN_PLANNED_RR", "人工最低盈亏比", "如 1.4"), ("KEY_AUTO_ORDER_ENABLED", "关键位自动单", "关闭后箱体/收敛/斐波等不自动开仓;支撑阻力提醒仍可用"), diff --git a/lib/instance/instance_settings_lib.py b/lib/instance/instance_settings_lib.py index cf1bcd7..8171796 100644 --- a/lib/instance/instance_settings_lib.py +++ b/lib/instance/instance_settings_lib.py @@ -53,6 +53,7 @@ def build_instance_settings_view( risk_status: Optional[dict[str, Any]] = None, trade_policy: Optional[TradePolicy] = None, data_export_version: int = 3, + open_guard_enabled: Optional[bool] = None, ) -> dict[str, Any]: rs = risk_status or {} sizing_mode = load_position_sizing_mode() @@ -63,6 +64,11 @@ def build_instance_settings_view( force_close_on = _env_bool("FORCE_CLOSE_ENABLED", False) force_close_hour = _env_int("FORCE_CLOSE_BJ_HOUR", 0) auto_transfer_on = _env_bool("AUTO_TRANSFER_ENABLED", False) + guard_on = ( + bool(open_guard_enabled) + if open_guard_enabled is not None + else _env_bool("TRADING_DAY_RESET_OPEN_GUARD_ENABLED", True) + ) sections: list[dict[str, Any]] = [] @@ -79,6 +85,12 @@ def build_instance_settings_view( f"北京时间 {reset_hour}:00", "新交易日统计与部分开仓限制以此为准", ), + _row( + "允许北京时间切点前开仓", + "已放开(允许开仓)" if not guard_on else "已限制(禁止开仓)", + f"关闭限制后,{reset_hour}:00 前也可斐波成交登记与人工下单;" + "环境配置「切点前禁止新开仓」(TRADING_DAY_RESET_OPEN_GUARD_ENABLED)", + ), _row( "单日开仓提醒", f"第 {alert_threshold} 次", diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html index b7a5e5c..f285a2b 100644 --- a/lib/instance/templates/embed_shell.html +++ b/lib/instance/templates/embed_shell.html @@ -7,7 +7,7 @@ - + {{ pwa_app_name }} diff --git a/lib/instance/templates/index.html b/lib/instance/templates/index.html index 8b83634..0a8cba5 100644 --- a/lib/instance/templates/index.html +++ b/lib/instance/templates/index.html @@ -17,7 +17,7 @@ {{ pwa_app_name }} - + 实时价格更新:--(北京时间 UTC+8) -{% if ui_open_guard_enabled %} -
- - - {% if open_guard_enabled %}已限制:{{ reset_hour }}:00 前不可开仓{% else %}已放开:{{ reset_hour }}:00 前允许开仓{% endif %} - -
-{% endif %} diff --git a/lib/options/templates/options_panel.html b/lib/options/templates/options_panel.html index 9c4db6c..c1fa0ad 100644 --- a/lib/options/templates/options_panel.html +++ b/lib/options/templates/options_panel.html @@ -7,8 +7,21 @@
-

期权下单 开平仓与监控说明

-

报价单位为每 1 ETH/BTC;1 张 = 0.01.默认选中最近一期到期,可手动改.列表含卖一/买一;T 型仅卖一(买方开仓),中间为跨式双买测算.环境配置「链上仅显示有卖一」开启时,隐藏无真实卖一或深度不足 1 张的合约(估算价 ~ 亦不显示).开仓只认真实卖一价且卖一深度≥1.链展示近 14 日到期.T 型默认 ATM ±5 档,可展开全部.平仓仅买一限价,见说明.

+

期权下单

+
+ 开仓规则说明 +
+

报价单位为每 1 ETH/BTC;1 张 = 0.01。默认选中最近一期到期,可手动改。

+
    +
  • 列表含卖一/买一;T 型仅卖一(买方开仓),中间为跨式双买测算。
  • +
  • 环境配置「链上仅显示有卖一」开启时,隐藏无真实卖一或深度不足 1 张的合约(估算价 ~ 亦不显示)。
  • +
  • 开仓只认真实卖一价且卖一深度≥1;无深度时面板显示参考标记价并禁用买入。
  • +
  • 链展示近 14 日到期;T 型默认 ATM ±5 档,可展开全部。
  • +
  • 平仓仅买一限价,详见说明文档。
  • +
+

打开《期权开平仓与监控说明》

+
+
@@ -300,4 +313,4 @@
- +