feat: daily volume top20 rank per exchange in market page

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 15:46:36 +08:00
parent 09eb9dc475
commit 4bf0c2363f
11 changed files with 763 additions and 6 deletions
+20
View File
@@ -206,6 +206,7 @@ def install_on_app(
views: dict,
ohlcv_fn=None,
account_fn=None,
volume_rank_fn=None,
):
app.config["HUB_CTX"] = {
"exchange": exchange,
@@ -217,6 +218,7 @@ def install_on_app(
"account_fn": account_fn,
"views": views,
"ohlcv_fn": ohlcv_fn,
"volume_rank_fn": volume_rank_fn,
}
install_hub_embed_headers(app)
configure_hub_embed_session(app)
@@ -507,6 +509,24 @@ def register_hub_routes(app):
}
)
@app.route("/api/hub/volume-rank")
@_hub_auth_required
def api_hub_volume_rank():
fn = _ctx().get("volume_rank_fn")
if not callable(fn):
return jsonify({"ok": False, "msg": "该实例未配置成交量排名接口"}), 501
top_raw = (request.args.get("top") or "").strip()
top_n = 20
if top_raw.isdigit():
top_n = int(top_raw)
try:
result = fn(top_n=top_n)
if isinstance(result, dict):
return jsonify(result)
return jsonify({"ok": False, "msg": "成交量排名返回格式无效"}), 500
except Exception as e:
return jsonify({"ok": False, "msg": str(e)}), 500
@app.route("/api/hub/ohlcv")
@_hub_auth_required
def api_hub_ohlcv():