fix: exchange-specific volume rank APIs for OKX and full top20

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-08 15:53:41 +08:00
parent 4bf0c2363f
commit 89a58c7323
8 changed files with 286 additions and 37 deletions
+5 -1
View File
@@ -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