ZhuLinsen/daily_stock_analysis · error · DataFetchError

[AlphaVantage] No time series data for

Error message

[AlphaVantage] No time series data for {symbol}

What it means

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.

Solutions

  1. Call the same endpoint manually with the key and inspect the raw JSON to see what AV actually returned.
  2. If metadata mentions 'premium', switch symbols/functions to free-tier ones or upgrade the key.
  3. Confirm the symbol has trading history (not a pre-IPO or empty listing).
  4. Fall back to Yfinance/Akshare for this symbol.

Example fix

# debugging recipe
import requests, os
r = requests.get('https://www.alphavantage.co/query', params={
    'function': 'TIME_SERIES_DAILY', 'symbol': sym,
    'apikey': os.environ['ALPHAVANTAGE_API_KEY']})
print(r.json())  # inspect why 'Time Series (Daily)' is absent
Defensive patterns

Strategy: fallback

Validate before calling

import requests, os
r = requests.get('https://www.alphavantage.co/query', params={
    'function': 'TIME_SERIES_DAILY', 'symbol': sym,
    'apikey': os.environ['ALPHAVANTAGE_API_KEY']}, timeout=10)
assert 'Time Series (Daily)' in r.json(), f'unexpected AV payload keys: {list(r.json())}

Try / catch

try:
    df = av_fetcher.fetch(sym, start, end)
except DataFetchError as e:
    if 'No time series data' in str(e):
        logger.info('AV returned no series for %s; using fallback', sym)
        df = yfinance_fetcher.fetch(sym, start, end)
    else:
        raise

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of ZhuLinsen/daily_stock_analysis@5159bd72e8 (2026-08-15). Data as JSON: /api/errors/5c11732feca68cdd. Report an issue: GitHub.

Appendix: source

Thrown at data_provider/alphavantage_fetcher.py:70

            'apikey': self._api_key,
        }

        try:
            self.random_sleep(0.5, 1.5)
            resp = requests.get(_AV_BASE_URL, params=params, timeout=30)
            resp.raise_for_status()
            data = resp.json()
        except Exception as e:
            raise DataFetchError(f"[AlphaVantage] HTTP request failed for {symbol}: {e}") from e

        if 'Note' in data:
            raise DataFetchError(f"[AlphaVantage] Rate limited: {data['Note']}")
        if 'Error Message' in data:
            raise DataFetchError(f"[AlphaVantage] API error for {symbol}: {data['Error Message']}")

        ts_key = 'Time Series (Daily)'
        if ts_key not in data or not data[ts_key]:
            raise DataFetchError(f"[AlphaVantage] No time series data for {symbol}")

        rows = []
        start = datetime.strptime(start_date, '%Y-%m-%d').date()
        end = datetime.strptime(end_date, '%Y-%m-%d').date()
        for date_str, values in data[ts_key].items():
            row_date = datetime.strptime(date_str, '%Y-%m-%d').date()
            if start <= row_date <= end:
                rows.append({
                    'date': date_str,
                    '1. open': float(values.get('1. open', 0)),
                    '2. high': float(values.get('2. high', 0)),
                    '3. low': float(values.get('3. low', 0)),
                    '4. close': float(values.get('4. close', 0)),
                    '5. volume': float(values.get('5. volume', 0)),
                })

        if not rows:
            raise DataFetchError(f"[AlphaVantage] No data in date range for {symbol}")

View on GitHub (pinned to 5159bd72e8)