fix(HEL-356): support Beijing exchange realtime quotes

Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
总管
2026-09-09 11:36:01 +08:00
co-authored by multica-agent
parent cb45d742da
commit abee8306be
5 changed files with 27 additions and 9 deletions
+11 -5
View File
@@ -128,13 +128,19 @@ class EastmoneyAdapter(MarketAdapter):
def fetch_quotes(self, codes: list[str]) -> list[dict[str, Any]]:
# Eastmoney ulist.np accepts ~60 secids per request; page remaining codes.
secids = []
suffixes: dict[str, str] = {}
for code in codes:
ts = str(code or "").upper()
symbol = ts.split(".")[0]
if ts.endswith(".SH") or symbol.startswith(("5", "6", "9")):
if ts.endswith(".BJ") or symbol.startswith(("4", "8", "92")):
secids.append(f"0.{symbol}")
suffixes[symbol] = "BJ"
elif ts.endswith(".SH") or symbol.startswith(("5", "6", "9")):
secids.append(f"1.{symbol}")
suffixes[symbol] = "SH"
else:
secids.append(f"0.{symbol}")
suffixes[symbol] = "SZ"
if not secids:
return []
result: list[dict[str, Any]] = []
@@ -154,7 +160,7 @@ class EastmoneyAdapter(MarketAdapter):
symbol = str(row.get("f12") or "")
if not symbol:
continue
ts_code = f"{symbol}.SH" if symbol.startswith(("5", "6", "9")) else f"{symbol}.SZ"
ts_code = f"{symbol}.{suffixes.get(symbol, 'SZ')}"
epoch = int(finite_number(row.get("f124")) or 0)
close = round4(finite_number(row.get("f2")))
previous = round4(finite_number(row.get("f18")))
@@ -462,10 +468,10 @@ def _normalize_market_quote(row: dict[str, Any]) -> dict[str, Any] | None:
if close <= 0 or previous_close <= 0:
return None
market = int(finite_number(row.get("f13")) or 0)
if market == 1 or symbol.startswith(("5", "6", "9")):
ts_code = f"{symbol}.SH"
elif symbol.startswith(("4", "8")):
if market == 0 and symbol.startswith(("4", "8", "92")):
ts_code = f"{symbol}.BJ"
elif market == 1 or symbol.startswith(("5", "6", "9")):
ts_code = f"{symbol}.SH"
else:
ts_code = f"{symbol}.SZ"
epoch = int(finite_number(row.get("f124")) or 0)