{"record":{"id":"86502a4071177ffd","repo":"ZhuLinsen/daily_stock_analysis","slug":"tencentfetcher-unsupported-stock-code-stock-code","errorCode":null,"errorMessage":"TencentFetcher unsupported stock code: {stock_code}","messagePattern":"TencentFetcher unsupported stock code: (.+?)","errorType":"exception","errorClass":"DataFetchError","httpStatus":null,"severity":"error","filePath":"data_provider/tencent_fetcher.py","lineNumber":46,"sourceCode":"\n    name = \"TencentFetcher\"\n    # This direct endpoint is the last-resort A-share daily fallback. Keeping\n    # it at priority 0 made a single Efinance failure skip the richer built-in\n    # fallback chain and try Tencent before AkShare/PyTDX/Baostock/YFinance.\n    priority = 5\n    allow_empty_daily_data = True\n\n    _KLINE_ENDPOINT = \"https://web.ifzq.gtimg.cn/appstock/app/fqkline/get\"\n    _HTTP_TIMEOUT_SECONDS = 8\n\n    def __init__(self) -> None:\n        self.priority = _read_tencent_priority()\n\n    def _fetch_raw_data(self, stock_code: str, start_date: str, end_date: str) -> pd.DataFrame:\n        code = normalize_stock_code(stock_code)\n        symbol = _to_tencent_symbol(code)\n        if not symbol:\n            raise DataFetchError(f\"TencentFetcher unsupported stock code: {stock_code}\")\n\n        lookback = _estimate_lookback_days(start_date=start_date, end_date=end_date)\n        explicit_start = _format_tencent_date(start_date)\n        explicit_end = _format_tencent_date(end_date)\n        explicit_window = (\n            f\"{explicit_start},{explicit_end}\"\n            if explicit_start and explicit_end\n            else \",\"\n        )\n        response = requests.get(\n            self._KLINE_ENDPOINT,\n            params={\"param\": f\"{symbol},day,{explicit_window},{lookback},qfq\"},\n            headers={\"User-Agent\": \"Mozilla/5.0\", \"Accept\": \"application/json,text/plain,*/*\"},\n            timeout=self._HTTP_TIMEOUT_SECONDS,\n        )\n        response.raise_for_status()\n        payload = response.json()\n        rows = _extract_kline_rows(payload, symbol=symbol)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/data_provider/tencent_fetcher.py#L28-L64","documentation":"DataFetchError raised in TencentFetcher._fetch_raw_data when _to_tencent_symbol(code) returns falsy after normalize_stock_code — the code's market/format cannot be mapped to a Tencent kline symbol (shXXXXXX/szXXXXXX/hkXXXXX/us... style). It fails before the HTTP request to web.ifzq.gtimg.cn is made.","triggerScenarios":"Calling TencentFetcher daily-data fetch with codes outside its supported markets or in unrecognized formats: BSE codes, exotic suffixes, malformed tickers.","commonSituations":"TencentFetcher enabled in a multi-market chain while the watchlist contains 北交所 or unusual codes; upstream normalization producing formats _to_tencent_symbol does not recognize; new market added without symbol mapping.","solutions":["Normalize the code first (normalize_stock_code) and confirm the market is supported by Tencent klines (A股, 港股, 美股主要标的).","Extend or fix _to_tencent_symbol if a legitimate market format is unmapped.","Let the DataFetcherManager fall back to the next provider on this error instead of calling TencentFetcher directly for exotic codes."],"exampleFix":"# before\ndf = tencent_fetcher.get_stock_data(\"832566\", start, end)  # DataFetchError if BSE unmapped\n\n# after\nfrom src.utils.stock_utils import normalize_stock_code\ncode = normalize_stock_code(raw)\nsymbol = _to_tencent_symbol(code)\nif symbol:\n    df = tencent_fetcher.get_stock_data(code, start, end)\nelse:\n    df = manager.get_stock_data(code, start, end)","handlingStrategy":"validation","validationCode":"from data_provider.tencent_fetcher import _to_tencent_symbol\nfrom src.utils.stock_utils import normalize_stock_code\n\nif not _to_tencent_symbol(normalize_stock_code(stock_code)):\n    df = manager.get_stock_data(stock_code, start, end)  # skip Tencent\nelse:\n    df = tencent_fetcher.get_stock_data(stock_code, start, end)","typeGuard":"def tencent_supports(code: str) -> bool:\n    \"\"\"True when the normalized code maps to a Tencent kline symbol.\"\"\"\n    return bool(_to_tencent_symbol(normalize_stock_code(code)))","tryCatchPattern":"try:\n    df = tencent_fetcher.get_stock_data(code, start, end)\nexcept DataFetchError as e:\n    if \"unsupported stock code\" in str(e):\n        df = manager.get_stock_data(code, start, end)\n    else:\n        raise","preventionTips":["Normalize codes once at ingestion and validate against each enabled provider's symbol mapper.","Keep provider coverage documented per market so routing surprises surface in review."],"tags":["tencent","symbol-mapping","market-coverage","validation"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}