feat中控桥接暴露已实现盈亏曲线接口,供中控数据统计拉取。

EOF

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-13 13:06:16 +08:00
parent b31f861596
commit 117f595b54
3 changed files with 26 additions and 2 deletions
+24
View File
@@ -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():
"""中控汇总用:窗口化已实现盈亏统计(不含浮盈进净盈亏主指标以外的展示字段仍附带)."""