{"record":{"id":"360fed08c98ece54","repo":"ZhuLinsen/daily_stock_analysis","slug":"tickflowfetcher-only-supports-a-share-etf-symbols","errorCode":null,"errorMessage":"TickFlowFetcher only supports A-share/ETF symbols","messagePattern":"TickFlowFetcher only supports A-share/ETF symbols","errorType":"exception","errorClass":"DataFetchError","httpStatus":null,"severity":"error","filePath":"data_provider/tickflow_fetcher.py","lineNumber":174,"sourceCode":"        return TickFlow(api_key=self.api_key, timeout=self.timeout)\n\n    def _get_client(self):\n        if not self.api_key:\n            return None\n        if self._client is not None:\n            return self._client\n\n        with self._client_lock:\n            if self._client is None:\n                self._client = self._build_client()\n            return self._client\n\n    def _fetch_raw_data(\n        self, stock_code: str, start_date: str, end_date: str\n    ) -> pd.DataFrame:\n        symbol = self._to_tickflow_symbol(stock_code)\n        if not symbol:\n            raise DataFetchError(\"TickFlowFetcher only supports A-share/ETF symbols\")\n\n        cache_key = self._daily_cache_key(symbol, start_date, end_date)\n        cached = self._get_daily_cache(cache_key)\n        if cached is not None:\n            return cached\n\n        client = self._get_client()\n        if client is None:\n            raise DataFetchError(\"TickFlow API key is not configured\")\n\n        request_count = self._daily_kline_count(start_date, end_date)\n        try:\n            df = client.klines.get(\n                symbol,\n                period=\"1d\",\n                count=request_count,\n                start_time=self._date_to_ms(start_date),\n                end_time=self._date_to_ms(end_date, end_of_day=True),","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/data_provider/tickflow_fetcher.py#L156-L192","documentation":"DataFetchError raised in TickFlowFetcher._fetch_raw_data when _to_tickflow_symbol(stock_code) returns falsy. TickFlow only serves A-share and ETF symbols, so HK/US/BSE or malformed codes are rejected before cache lookup or any API request.","triggerScenarios":"Passing non-A-share codes (US tickers, HK codes, BSE codes) or unrecognizable A-share formats to TickFlowFetcher._fetch_raw_data.","commonSituations":"TickFlowFetcher configured in a chain that also receives HK/US names from a mixed portfolio; code normalization drift making valid A-share codes unrecognizable to _to_tickflow_symbol.","solutions":["Restrict TickFlowFetcher to A-share/ETF routing and send other markets to their dedicated providers.","Verify _to_tickflow_symbol handles your code format; extend it if a valid A-share/ETF format is rejected.","Rely on manager-level fallback on DataFetchError when routing cannot be guaranteed."],"exampleFix":"# before\ndf = tickflow_fetcher.get_stock_data(\"AAPL\", start, end)  # DataFetchError\n\n# after\nsymbol = tickflow_fetcher._to_tickflow_symbol(code)\nif symbol:\n    df = tickflow_fetcher.get_stock_data(code, start, end)\nelse:\n    df = manager.get_stock_data(code, start, end)","handlingStrategy":"validation","validationCode":"symbol = tickflow_fetcher._to_tickflow_symbol(stock_code)\nif not symbol:\n    df = manager.get_stock_data(stock_code, start, end)  # non A-share/ETF goes elsewhere\nelse:\n    df = tickflow_fetcher.get_stock_data(stock_code, start, end)","typeGuard":"def tickflow_supports(code: str) -> bool:\n    \"\"\"True when the code is an A-share/ETF symbol TickFlow can serve.\"\"\"\n    return bool(tickflow_fetcher._to_tickflow_symbol(code))","tryCatchPattern":"try:\n    df = tickflow_fetcher.get_stock_data(code, start, end)\nexcept DataFetchError as e:\n    if \"only supports A-share/ETF\" in str(e):\n        df = manager.get_stock_data(code, start, end)\n    else:\n        raise","preventionTips":["Confine TickFlowFetcher to the A-share/ETF chain.","Add symbol-mapper unit tests for every code format your pipeline ingests."],"tags":["tickflow","market-coverage","symbol-mapping","validation"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}