fix(HEL-494): 数据中枢独占调度,主网站不再回退旧接口
主网站只向中枢要业务数据;来源选择、切源、补数全部在中枢内部完成,失败不再走东财/腾讯/Tushare 保底。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
co-authored by
Cursor
multica-agent
parent
ef13d6feb5
commit
0b8419abca
@@ -87,12 +87,46 @@ class V1API:
|
||||
return self.index_quotes(q)
|
||||
if path == "/v1/intraday/points":
|
||||
return self.intraday_points(q)
|
||||
if path == "/v1/sectors/quote":
|
||||
return self.sector_quote(q)
|
||||
if path == "/v1/limit-pool":
|
||||
return self.limit_pool(q)
|
||||
if path == "/v1/query":
|
||||
return self.query_api(q)
|
||||
if path == "/v1/datasets/status":
|
||||
return self.dataset_status(q.get("date") or "")
|
||||
if path == "/v1/batches":
|
||||
return self.batches(q.get("date") or "", q.get("dataset") or "")
|
||||
raise ApiError("INVALID_ARGUMENT", f"unknown endpoint: {path}")
|
||||
|
||||
def query_api(self, body: dict[str, Any]) -> dict[str, Any]:
|
||||
from datahub.steward import steward_query
|
||||
|
||||
payload = dict(body or {})
|
||||
raw_params = payload.get("params")
|
||||
if isinstance(raw_params, str):
|
||||
payload["params"] = _parse_json(raw_params) or {}
|
||||
return steward_query(self, payload)
|
||||
|
||||
def sector_quote(self, q: dict[str, str]) -> dict[str, Any]:
|
||||
from datahub.realtime_serve import RealtimeApiError, fetch_sector_quote
|
||||
|
||||
code = str(q.get("code") or q.get("ts_code") or "").strip()
|
||||
if not code:
|
||||
raise ApiError("INVALID_ARGUMENT", "code is required")
|
||||
try:
|
||||
return fetch_sector_quote(self.db, code, str(q.get("date") or ""))
|
||||
except RealtimeApiError as exc:
|
||||
raise ApiError(exc.code, exc.message) from exc
|
||||
|
||||
def limit_pool(self, q: dict[str, str]) -> dict[str, Any]:
|
||||
from datahub.realtime_serve import RealtimeApiError, fetch_limit_pool
|
||||
|
||||
try:
|
||||
return fetch_limit_pool(self.db, str(q.get("date") or q.get("trade_date") or ""))
|
||||
except RealtimeApiError as exc:
|
||||
raise ApiError(exc.code, exc.message) from exc
|
||||
|
||||
def health(self) -> dict[str, Any]:
|
||||
today = yyyymmdd(now_shanghai())
|
||||
cal = self.db.fetchone(
|
||||
|
||||
Reference in New Issue
Block a user