From 117f595b543a0231d717160adf2b66795580bd14 Mon Sep 17 00:00:00 2001 From: dekun Date: Tue, 13 Oct 2026 13:06:16 +0800 Subject: [PATCH] =?UTF-8?q?feat=E4=B8=AD=E6=8E=A7=E6=A1=A5=E6=8E=A5?= =?UTF-8?q?=E6=9A=B4=E9=9C=B2=E5=B7=B2=E5=AE=9E=E7=8E=B0=E7=9B=88=E4=BA=8F?= =?UTF-8?q?=E6=9B=B2=E7=BA=BF=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BE=9B=E4=B8=AD?= =?UTF-8?q?=E6=8E=A7=E6=95=B0=E6=8D=AE=E7=BB=9F=E8=AE=A1=E6=8B=89=E5=8F=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit EOF Co-authored-by: Cursor --- lib/common/static/options_data_stats.js | 2 +- lib/hub/hub_bridge_register.py | 24 +++++++++++++++++++ .../templates/options_data_stats_panel.html | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/common/static/options_data_stats.js b/lib/common/static/options_data_stats.js index 1675c51..36e9af2 100644 --- a/lib/common/static/options_data_stats.js +++ b/lib/common/static/options_data_stats.js @@ -179,7 +179,7 @@ svg.innerHTML = '暂无采样数据,请稍后再看'; + '" font-size="13">暂无已实现盈亏数据'; return; } diff --git a/lib/hub/hub_bridge_register.py b/lib/hub/hub_bridge_register.py index 3feaa6d..7a4234a 100644 --- a/lib/hub/hub_bridge_register.py +++ b/lib/hub/hub_bridge_register.py @@ -275,6 +275,30 @@ def register_hub_bridge_routes(app: Flask, app_module: Any) -> None: return jsonify({"ok": False, "msg": str(e), "version": 1, "enabled": True}), 500 return jsonify(_enrich_hub_protocol(snap, app_module=app_module)) + @app.route("/api/hub/options/pnl_curve") + def api_hub_options_pnl_curve(): + """中控汇总用:累计已实现盈亏曲线(划转/提现不影响).""" + if not hub_bridge_token_ok(request.headers): + return jsonify({"ok": False, "msg": "未授权", "version": 1}), 401 + hub_ctx = app.config.get("HUB_CTX") or {} + cfg = hub_ctx.get("options_cfg") + if not isinstance(cfg, dict) or not callable(cfg.get("get_db")): + return jsonify({"ok": False, "msg": "期权未就绪", "version": 1}), 503 + range_key = (request.args.get("range") or request.args.get("window") or "7d").strip() + conn = cfg["get_db"]() + try: + from lib.instance.instance_cash_sample_lib import ( + query_realized_pnl_series_with_db, + ) + + out = query_realized_pnl_series_with_db(conn, range_key=range_key) + out["version"] = 1 + return jsonify(out) + except Exception as e: + return jsonify({"ok": False, "msg": str(e) or "曲线失败", "version": 1}), 500 + finally: + conn.close() + @app.route("/api/hub/options/stats") def api_hub_options_stats(): """中控汇总用:窗口化已实现盈亏统计(不含浮盈进净盈亏主指标以外的展示字段仍附带).""" diff --git a/lib/instance/templates/options_data_stats_panel.html b/lib/instance/templates/options_data_stats_panel.html index 935491a..5f03d64 100644 --- a/lib/instance/templates/options_data_stats_panel.html +++ b/lib/instance/templates/options_data_stats_panel.html @@ -82,4 +82,4 @@ - +