fix: exchange-specific volume rank APIs for OKX and full top20
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -381,14 +381,18 @@ def _refresh_volume_ranks(*, force: bool = False) -> dict:
|
||||
if not ex_key or not ex.get("enabled"):
|
||||
continue
|
||||
resp = _fetch_instance_volume_rank_sync(ex, top_n=TOP_N_DEFAULT)
|
||||
if resp.get("ok"):
|
||||
if resp.get("ok") and resp.get("items"):
|
||||
cache = merge_exchange_rank(cache, ex_key, resp)
|
||||
else:
|
||||
msg = str(resp.get("msg") or resp.get("error") or "拉取失败")
|
||||
if resp.get("ok") and not resp.get("items"):
|
||||
msg = msg if msg != "拉取失败" else "无有效成交额数据"
|
||||
errors.append(f"{ex_key}:{msg}")
|
||||
exchanges = dict(cache.get("exchanges") or {})
|
||||
prev = dict(exchanges.get(ex_key) or {})
|
||||
prev["error"] = msg
|
||||
if not prev.get("items"):
|
||||
prev["items"] = []
|
||||
exchanges[ex_key] = prev
|
||||
cache["exchanges"] = exchanges
|
||||
cache["rank_date"] = expected
|
||||
|
||||
@@ -2621,14 +2621,23 @@
|
||||
elVolRankList.innerHTML = "";
|
||||
if (!data || !data.ok || !data.items || !data.items.length) {
|
||||
elVolRankMeta.textContent =
|
||||
(data && data.msg) || "暂无排名数据(请稍后或检查实例 /api/hub/volume-rank)";
|
||||
(data && data.msg) ||
|
||||
"暂无排名数据(请 pm2 restart 四实例与 manual-trading-hub 后重试)";
|
||||
return;
|
||||
}
|
||||
const resetHour = data.reset_hour != null ? data.reset_hour : 8;
|
||||
const rankDate = data.rank_date || "—";
|
||||
const updated = data.updated_at || "—";
|
||||
const total = data.total_symbols != null ? data.total_symbols : "";
|
||||
elVolRankMeta.textContent =
|
||||
"昨日成交 Top20 · 交易日 " + rankDate + " · 每早 " + resetHour + ":00 更新 · " + updated;
|
||||
"昨日成交 Top20 · 交易日 " +
|
||||
rankDate +
|
||||
" · 每早 " +
|
||||
resetHour +
|
||||
":00 更新" +
|
||||
(total ? " · 全市场 " + total + " 个" : "") +
|
||||
" · " +
|
||||
updated;
|
||||
const curSym = (elSymbol && elSymbol.value.trim().toUpperCase()) || "";
|
||||
data.items.forEach(function (row) {
|
||||
const li = document.createElement("li");
|
||||
|
||||
Reference in New Issue
Block a user