{"record":{"id":"5c11732feca68cdd","repo":"ZhuLinsen/daily_stock_analysis","slug":"alphavantage-no-time-series-data-for-symbol","errorCode":null,"errorMessage":"[AlphaVantage] No time series data for {symbol}","messagePattern":"\\[AlphaVantage\\] No time series data for (.+?)","errorType":"exception","errorClass":"DataFetchError","httpStatus":null,"severity":"error","filePath":"data_provider/alphavantage_fetcher.py","lineNumber":70,"sourceCode":"            'apikey': self._api_key,\n        }\n\n        try:\n            self.random_sleep(0.5, 1.5)\n            resp = requests.get(_AV_BASE_URL, params=params, timeout=30)\n            resp.raise_for_status()\n            data = resp.json()\n        except Exception as e:\n            raise DataFetchError(f\"[AlphaVantage] HTTP request failed for {symbol}: {e}\") from e\n\n        if 'Note' in data:\n            raise DataFetchError(f\"[AlphaVantage] Rate limited: {data['Note']}\")\n        if 'Error Message' in data:\n            raise DataFetchError(f\"[AlphaVantage] API error for {symbol}: {data['Error Message']}\")\n\n        ts_key = 'Time Series (Daily)'\n        if ts_key not in data or not data[ts_key]:\n            raise DataFetchError(f\"[AlphaVantage] No time series data for {symbol}\")\n\n        rows = []\n        start = datetime.strptime(start_date, '%Y-%m-%d').date()\n        end = datetime.strptime(end_date, '%Y-%m-%d').date()\n        for date_str, values in data[ts_key].items():\n            row_date = datetime.strptime(date_str, '%Y-%m-%d').date()\n            if start <= row_date <= end:\n                rows.append({\n                    'date': date_str,\n                    '1. open': float(values.get('1. open', 0)),\n                    '2. high': float(values.get('2. high', 0)),\n                    '3. low': float(values.get('3. low', 0)),\n                    '4. close': float(values.get('4. close', 0)),\n                    '5. volume': float(values.get('5. volume', 0)),\n                })\n\n        if not rows:\n            raise DataFetchError(f\"[AlphaVantage] No data in date range for {symbol}\")","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/ZhuLinsen/daily_stock_analysis/blob/5159bd72e8373d215492dff122acc9d389e219c9/data_provider/alphavantage_fetcher.py#L52-L88","documentation":"A DataFetchError raised by AlphaVantageFetcher._fetch_raw_data when the response JSON lacks the 'Time Series (Daily)' key or that key maps to an empty object. This means AV neither reported a Note (rate limit) nor an Error Message, but simply returned no series payload — typically a key-privilege or empty-response condition rather than a network fault.","triggerScenarios":"Using a free key to request a function/symbol combination reserved for premium (some responses omit the series), AV infrastructure returning a bare metadata-only object, or a symbol with no daily data at all (recent IPO with no trading history, some FX/crypto-style responses).","commonSituations":"Free-tier key hitting a premium dataset; brand-new IPO before first trading day; occasional AV API shape drift where the series key is renamed.","solutions":["Call the same endpoint manually with the key and inspect the raw JSON to see what AV actually returned.","If metadata mentions 'premium', switch symbols/functions to free-tier ones or upgrade the key.","Confirm the symbol has trading history (not a pre-IPO or empty listing).","Fall back to Yfinance/Akshare for this symbol."],"exampleFix":"# debugging recipe\nimport requests, os\nr = requests.get('https://www.alphavantage.co/query', params={\n    'function': 'TIME_SERIES_DAILY', 'symbol': sym,\n    'apikey': os.environ['ALPHAVANTAGE_API_KEY']})\nprint(r.json())  # inspect why 'Time Series (Daily)' is absent","handlingStrategy":"fallback","validationCode":"import requests, os\nr = requests.get('https://www.alphavantage.co/query', params={\n    'function': 'TIME_SERIES_DAILY', 'symbol': sym,\n    'apikey': os.environ['ALPHAVANTAGE_API_KEY']}, timeout=10)\nassert 'Time Series (Daily)' in r.json(), f'unexpected AV payload keys: {list(r.json())}","typeGuard":null,"tryCatchPattern":"try:\n    df = av_fetcher.fetch(sym, start, end)\nexcept DataFetchError as e:\n    if 'No time series data' in str(e):\n        logger.info('AV returned no series for %s; using fallback', sym)\n        df = yfinance_fetcher.fetch(sym, start, end)\n    else:\n        raise","preventionTips":["Inspect the raw AV JSON when this first appears — it distinguishes premium-gating from empty symbols.","Keep premium-only datasets off free-tier keys.","Monitor AV API changelog for series-key renames."],"tags":["alphavantage","empty-response","api-contract","premium-tier"],"backgroundTag":null,"analyzedSha":"5159bd72e8373d215492dff122acc9d389e219c9","analyzedAt":"2026-08-15T01:59:36.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}