diff --git a/app.py b/app.py index ba57417..07a108a 100644 --- a/app.py +++ b/app.py @@ -6617,7 +6617,7 @@ def login(): return render_template( "login.html", exchange_display=EXCHANGE_DISPLAY_NAME, - pwa_app_name="OKX 交易系统", + pwa_app_name="okx对冲", ) @app.route("/logout") @@ -7042,7 +7042,7 @@ def api_sync_exchange_pnl(): @app.route("/") @login_required def index(): - return redirect("/trade") + return redirect("/hedge-plan") @app.route("/key_monitor") @@ -7064,19 +7064,17 @@ def trade_page(): @app.route("/records") @login_required def records_page(): - redir = redirect_to_embed_shell_if_enabled("records") - if redir is not None: - return redir - return render_main_page("records") + # CoinOX 已移除「交易记录与复盘」 + flash("CoinOX 不提供交易记录与复盘,请使用期权复盘或对冲计划") + return redirect("/hedge-plan") @app.route("/stats") @login_required def stats_page(): - redir = redirect_to_embed_shell_if_enabled("stats") - if redir is not None: - return redir - return render_main_page("stats") + # CoinOX 已移除全站「统计分析」(对冲计划内统计仍保留) + flash("CoinOX 不提供全站统计分析,请在对冲计划内查看") + return redirect("/hedge-plan") @app.route("/dashboard") @@ -9297,21 +9295,11 @@ def api_journal_upload_slot(): return jsonify(payload), code -from lib.instance.records_api_register import register_trade_records_api - -register_trade_records_api( - app, - login_required=login_required, - get_db=get_db, - list_window_from_request=_list_window_from_request, - utc_window_to_bj_sql_strings=utc_window_to_bj_sql_strings, - sql_list_time_field=sql_list_time_field, - to_effective_trade_dict=to_effective_trade_dict, - filter_trade_records_excluding_miss=filter_trade_records_excluding_miss, - app_tz=APP_TZ, - format_price_fn=format_price_for_symbol, - sync_exchange_pnl_fn=lambda conn: sync_trade_records_from_exchange(conn, force=False), -) +# CoinOX: 不再注册 /api/trade_records(交易记录与复盘已下线) +@app.route("/api/trade_records") +@login_required +def api_trade_records_removed(): + return jsonify({"ok": False, "msg": "CoinOX 已移除交易记录与复盘"}), 410 def _dashboard_fetch_options_positions(): diff --git a/lib/env/env_schema.py b/lib/env/env_schema.py index db209cd..52cef47 100644 --- a/lib/env/env_schema.py +++ b/lib/env/env_schema.py @@ -179,6 +179,10 @@ SELECT_OPTIONS: dict[str, tuple[tuple[str, str], ...]] = { ("true", "以期权为主"), ("false", "保险模式"), ), + "SIM_DEFAULT_MODE": ( + ("sim", "模拟盘"), + ("live", "实盘"), + ), } _SELECT_ALIASES: dict[str, dict[str, str]] = { diff --git a/lib/env/env_ui_manifest.py b/lib/env/env_ui_manifest.py index ea58a5a..4d39752 100644 --- a/lib/env/env_ui_manifest.py +++ b/lib/env/env_ui_manifest.py @@ -44,6 +44,7 @@ _EXCHANGE_LIVE_FIELDS: dict[str, list[tuple[str, str, str]]] = { ], } +# 通用共享区(三所模板遗留);CoinOX 用下方 _COINOX_SHARED_SECTIONS _SHARED_SECTIONS: list[dict[str, Any]] = [ { "title": "企业微信", @@ -118,6 +119,47 @@ _SHARED_SECTIONS: list[dict[str, Any]] = [ }, ] +# CoinOX env 页:去掉关键位/AI复盘/永续手工单等无关项 +_COINOX_SHARED_SECTIONS: list[dict[str, Any]] = [ + { + "title": "企业微信", + "fields": [ + ("WECHAT_WEBHOOK", "机器人 Webhook", "行情与风控推送地址"), + ("WECHAT_TIMEOUT_SECONDS", "推送超时(秒)", "默认 10"), + ], + }, + { + "title": "资金与杠杆", + "fields": [ + ("POSITION_SIZING_MODE", "计仓模式", "切换须无仓后重启"), + ("RISK_PERCENT", "以损定仓风险%", "单笔风险占资金比例"), + ("FULL_MARGIN_BUFFER_RATIO", "全仓资金缓冲比例", "如 0.98"), + ("BTC_LEVERAGE", "BTC 默认杠杆", ""), + ("ALT_LEVERAGE", "山寨默认杠杆", ""), + ("TRADING_DAY_RESET_HOUR", "交易日切点(北京时间)", "整点,默认 8"), + ], + }, + { + "title": "模拟盘", + "fields": [ + ("SIM_DEFAULT_MODE", "默认交易模式", "sim=模拟资金;live=实盘"), + ("SIM_INITIAL_EQUITY_USDT", "模拟初始权益(USDT)", ""), + ("SIM_FEE_RATE", "模拟手续费率", "默认 0.0005"), + ], + }, + { + "title": "自动划转", + "fields": [ + ("AUTO_TRANSFER_ENABLED", "启用自动划转", ""), + ("AUTO_TRANSFER_AMOUNT", "目标余额(U)", "交易账户目标 USDT"), + ("AUTO_TRANSFER_FROM", "划出账户", "余额不足时从此账户划入交易账户"), + ("AUTO_TRANSFER_TO", "划入账户", "目标余额所在账户,一般为 swap"), + ("AUTO_TRANSFER_BJ_HOUR", "执行整点(北京时间)", ""), + ("TRANSFER_CCY", "划转币种", ""), + ], + }, +] + _MODE_SECTION: dict[str, Any] = { "title": "期权/对冲模式", "exchanges": frozenset({"okx"}), @@ -481,7 +523,8 @@ def ui_sections_for_exchange( sections: list[dict[str, Any]] = [] live_fields = _EXCHANGE_LIVE_FIELDS.get(ex, _EXCHANGE_LIVE_FIELDS["okx"]) sections.append({"title": "交易所与实盘", "fields": live_fields}) - sections.extend(_SHARED_SECTIONS) + # CoinOX(okx)用精简共享区;其它交易所保留完整遗留分区 + sections.extend(_COINOX_SHARED_SECTIONS if ex == "okx" else _SHARED_SECTIONS) if ex in _MODE_SECTION.get("exchanges", frozenset()): from lib.hedge_plan.okx_trade_mode_lib import normalize_okx_trade_mode diff --git a/lib/instance/instance_display_prefs_lib.py b/lib/instance/instance_display_prefs_lib.py index c6b1833..44af683 100644 --- a/lib/instance/instance_display_prefs_lib.py +++ b/lib/instance/instance_display_prefs_lib.py @@ -14,8 +14,9 @@ DEFAULT_INSTANCE_DISPLAY: dict[str, bool] = { "show_nav_trade": False, "show_nav_strategy": False, "show_nav_strategy_records": False, - "show_nav_records": True, - "show_nav_stats": True, + # CoinOX: 已去掉交易记录与复盘 / 全站统计分析 + "show_nav_records": False, + "show_nav_stats": False, "show_nav_risk_policy": True, "show_nav_system_guide": False, "show_nav_env_config": True, @@ -75,6 +76,16 @@ def normalize_display_prefs(raw: dict | None) -> dict[str, bool]: for key in DEFAULT_INSTANCE_DISPLAY: if key in raw: out[key] = bool(raw[key]) + # CoinOX 产品面强制隐藏已下线入口(忽略库里旧开关) + out["show_nav_records"] = False + out["show_nav_stats"] = False + out["show_nav_dashboard"] = False + out["show_nav_account_ledger"] = False + out["show_nav_key_monitor"] = False + out["show_nav_trade"] = False + out["show_nav_strategy"] = False + out["show_nav_strategy_records"] = False + out["show_nav_system_guide"] = False return out @@ -117,21 +128,13 @@ def tab_allowed(tab: str, display: Optional[dict[str, bool]] = None) -> bool: def display_meta_for_ui() -> list[dict[str, Any]]: + # CoinOX 顶栏仅保留期权/对冲相关入口 nav_keys = [ - "show_nav_dashboard", - "show_nav_account_ledger", - "show_nav_key_monitor", - "show_nav_trade", - "show_nav_strategy", - "show_nav_strategy_records", - "show_nav_records", - "show_nav_stats", - "show_nav_risk_policy", - "show_nav_system_guide", - "show_nav_env_config", "show_nav_options", "show_nav_options_review", "show_nav_hedge_plan", + "show_nav_risk_policy", + "show_nav_env_config", ] settings_keys = [ "show_settings_transfer", diff --git a/lib/instance/instance_embed_lib.py b/lib/instance/instance_embed_lib.py index 29e1f4c..3610962 100644 --- a/lib/instance/instance_embed_lib.py +++ b/lib/instance/instance_embed_lib.py @@ -214,7 +214,7 @@ def pwa_app_name(exchange_key: str) -> str: ex = (exchange_key or "").strip().lower() return { "binance": "Binance 交易系统", - "okx": "OKX 交易系统", + "okx": "okx对冲", "gate": "Gate 交易系统", }.get(ex, "交易系统") diff --git a/lib/instance/templates/embed_page_fragment.html b/lib/instance/templates/embed_page_fragment.html index e64fd96..608e63b 100644 --- a/lib/instance/templates/embed_page_fragment.html +++ b/lib/instance/templates/embed_page_fragment.html @@ -292,9 +292,6 @@ - {% if page == 'records' %} - {% include 'records_panel.html' %} - {% endif %} {% if page == 'env_config' %} {% include 'env_config_panel.html' %} @@ -304,49 +301,6 @@ {% include 'risk_policy_panel.html' %} {% endif %} - {% if page == 'system_guide' %} - {% include 'system_guide_panel.html' %} - {% endif %} - {% if page == 'settings' %} {% include 'settings_panel.html' %} {% endif %} - - {% if page == 'stats' %} -
-
-

数据统计

- -
-
-
- 统计分析按北京时间 {{ stats_bundle.stats_reset_hour }}:00切日计入(与顶栏 UTC 列表窗无关).历史总开仓(累计): - {{ stats_bundle.total_opens_all }} 次 -
-
- -
- {% for seg in stats_bundle.segments %} - - {% endfor %} -
-
- {% endif %} diff --git a/lib/instance/templates/embed_shell.html b/lib/instance/templates/embed_shell.html index f596b3e..c963a69 100644 --- a/lib/instance/templates/embed_shell.html +++ b/lib/instance/templates/embed_shell.html @@ -28,25 +28,9 @@ >
-

加密货币|交易监控 + AI复盘一体化

+

okx对冲