feat中控桥接暴露已实现盈亏曲线接口,供中控数据统计拉取。
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -179,7 +179,7 @@
|
|||||||
svg.innerHTML =
|
svg.innerHTML =
|
||||||
'<text x="320" y="120" text-anchor="middle" fill="' +
|
'<text x="320" y="120" text-anchor="middle" fill="' +
|
||||||
muted +
|
muted +
|
||||||
'" font-size="13">暂无采样数据,请稍后再看</text>';
|
'" font-size="13">暂无已实现盈亏数据</text>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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({"ok": False, "msg": str(e), "version": 1, "enabled": True}), 500
|
||||||
return jsonify(_enrich_hub_protocol(snap, app_module=app_module))
|
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")
|
@app.route("/api/hub/options/stats")
|
||||||
def api_hub_options_stats():
|
def api_hub_options_stats():
|
||||||
"""中控汇总用:窗口化已实现盈亏统计(不含浮盈进净盈亏主指标以外的展示字段仍附带)."""
|
"""中控汇总用:窗口化已实现盈亏统计(不含浮盈进净盈亏主指标以外的展示字段仍附带)."""
|
||||||
|
|||||||
@@ -82,4 +82,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<script src="/static/options_data_stats.js?v=3"></script>
|
<script src="/static/options_data_stats.js?v=4"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user