fix(HEL-494): keep filtered reference lookups inside datahub

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总管
2026-09-09 00:50:33 +08:00
co-authored by multica-agent
parent 41f8509a98
commit b950ea4344
2 changed files with 41 additions and 3 deletions
+11 -3
View File
@@ -202,6 +202,11 @@ def _try_published(api, api_name: str, dataset: str, params: dict[str, Any], fie
return None
if dataset == "stocks":
rows = _filter_stocks(rows, params)
# The published master is intentionally the active list. Historical
# delisted/paused lookups still belong in the hub, so use its live
# Tushare adapter when those filters cannot be answered by the snapshot.
if not rows and any(params.get(key) for key in ("ts_code", "list_status", "name")):
return None
if dataset == "calendar":
rows = _filter_calendar(rows, params)
native = _to_tushare_native(dataset, rows)
@@ -312,9 +317,12 @@ def _live_cache_key(api_name: str, params: dict[str, Any], fields: str) -> str:
def _hub_query(params: dict[str, Any], **extra: Any) -> dict[str, str]:
query = {key: str(value) for key, value in extra.items() if value not in (None, "")}
date = yyyymmdd(params.get("trade_date") or params.get("date") or "")
start = yyyymmdd(params.get("start_date") or params.get("from") or date)
end = yyyymmdd(params.get("end_date") or params.get("to") or date)
raw_date = params.get("trade_date") or params.get("date") or ""
date = yyyymmdd(raw_date) if raw_date else ""
raw_start = params.get("start_date") or params.get("from") or date
raw_end = params.get("end_date") or params.get("to") or date
start = yyyymmdd(raw_start) if raw_start else ""
end = yyyymmdd(raw_end) if raw_end else ""
code = str(params.get("ts_code") or params.get("code") or "").strip()
if code:
query["code"] = code