summaryrefslogtreecommitdiff
path: root/worker
diff options
context:
space:
mode:
Diffstat (limited to 'worker')
-rw-r--r--worker/data.py30
1 files changed, 19 insertions, 11 deletions
diff --git a/worker/data.py b/worker/data.py
index 841a1eb..13f8808 100644
--- a/worker/data.py
+++ b/worker/data.py
@@ -66,13 +66,20 @@ def split_identity(instrument: dict) -> tuple[str, str]:
raise DataError("bad_identity", f"unknown exchange prefix: {exch}")
else:
code = symbol
- market = instrument.get("market", "cn")
- if market != "cn":
- raise DataError("unsupported_market", f"market not supported by this adapter: {market}")
- if len(code) == 6 and code[0] in "369":
- exch = "SH"
+ market = str(instrument.get("market", "cn")).strip() or "cn"
+ # The server persists the user-facing market field verbatim (SH/SZ/BJ
+ # from the manual-entry form); "cn" (search-sourced items, any case)
+ # keeps the original code-prefix inference. Unknown markets must still
+ # be rejected — never guessed.
+ if market.upper() in IDENTITY_EXCHANGES:
+ exch = market.upper()
+ elif market.lower() == "cn":
+ if len(code) == 6 and code[0] in "369":
+ exch = "SH"
+ else:
+ exch = "SZ"
else:
- exch = "SZ"
+ raise DataError("unsupported_market", f"market not supported by this adapter: {market}")
if not code.isdigit() or len(code) != 6:
raise DataError("bad_identity", "A-share code must be a 6-digit number")
return exch, code
@@ -157,11 +164,12 @@ def _fetch_sina(instrument: dict, start: str, end: str,
# requested window (ISO strings compare lexicographically like dates)
df = df[(df["date"] >= start) & (df["date"] <= end)].reset_index(drop=True)
df.attrs["source_warnings"] = [
- "sina returns the full trading history without date parameters; sliced "
- "locally to the requested range; data is unadjusted (no adjust parameter)",
- "sina volume unit is 股 (shares); verified to be 100x the 手 (lots) "
- "convention used by lot-based providers on the same session "
- "(2026-09-17 evidence, docs/recovery-01-plan.md)",
+ "sina fund_etf_hist_sina has no date-range parameter: the provider "
+ "returned its available history and it was sliced locally to the "
+ "requested range (actual coverage differences are reported separately)",
+ "sina ETF klines are unadjusted: the interface has no adjust parameter",
+ "sina fund_etf_hist_sina 成交量单位为股;数值按 provider 原样保留,未做换算或取整。"
+ "与其他行情接口对比时,请先核对各 provider 自己公布的口径,不要按惯例直接换算",
]
return FetchResult(df, endpoint, params, raw, "sina")