we-promise/sure · error · Provider::AlphaVantage::InvalidSecurityPriceError

No time series data returned for symbol #{av_symbol}

Error message

No time series data returned for symbol #{av_symbol}

What it means

The TIME_SERIES_DAILY fetch raises Provider::AlphaVantage::InvalidSecurityPriceError 'No time series data returned for symbol X' when the response JSON lacks the 'Time Series (Daily)' key after check_api_error! passed. Typical cause: Alpha Vantage returned an empty payload for an unknown/invalid symbol (HTTP 200 with {} or an informational key not covered by check_api_error!).

Source

Thrown at app/models/provider/alpha_vantage.rb:190

  end

  def fetch_security_prices(symbol:, exchange_operating_mic: nil, start_date:, end_date:)
    with_provider_response do
      av_symbol = to_av_symbol(symbol, exchange_operating_mic)

      throttle_request
      response = client.get("#{base_url}/query") do |req|
        req.params["function"] = "TIME_SERIES_DAILY"
        req.params["symbol"] = av_symbol
        req.params["outputsize"] = "compact"
      end

      parsed = JSON.parse(response.body)
      check_api_error!(parsed)
      time_series = parsed.dig("Time Series (Daily)")

      if time_series.nil?
        raise InvalidSecurityPriceError, "No time series data returned for symbol #{av_symbol}"
      end

      currency = infer_currency_from_symbol(av_symbol)

      time_series.filter_map do |date_str, values|
        date = Date.parse(date_str)
        next unless date >= start_date && date <= end_date

        price = values["4. close"]

        if price.nil? || price.to_f <= 0
          Rails.logger.warn("#{self.class.name} returned invalid price data for security #{symbol} on: #{date_str}.  Price data: #{price.inspect}")
          next
        end

        Price.new(
          symbol: symbol,
          date: date,

View on GitHub (pinned to e69894adb9)

Solutions

  1. Confirm the symbol on Alpha Vantage; fix the ticker or the exchange_operating_mic used for suffix mapping.
  2. Log response.body when the key is missing to catch new undocumented AV message keys and extend check_api_error!.
  3. Rescue InvalidSecurityPriceError at the sync level and mark the security as unpriced rather than aborting.
  4. For search-driven flows, resolve the AV ticker via search_securities before fetching prices.

Example fix

# before
data = provider.fetch_security_prices(symbol: "INVALID1", start_date: from, end_date: to)

# after
begin
  data = provider.fetch_security_prices(symbol: symbol, start_date: from, end_date: to)
rescue Provider::AlphaVantage::InvalidSecurityPriceError => e
  Rails.logger.warn("AV price fetch failed: #{e.message}")
  data = ProviderResponse.new(data: [], error: nil)
end
Defensive patterns

Strategy: try-catch

Try / catch

begin
  provider.fetch_security_prices(symbol: s, start_date: a, end_date: b)
rescue Provider::AlphaVantage::InvalidSecurityPriceError => e
  Rails.logger.warn("AV time series missing for #{s}: #{e.message}")
  mark_unpriceable(s)
end

Prevention

When it happens

Trigger: fetch_security_prices with a symbol AV does not recognize (wrong ticker or wrong MIC-derived suffix); API returning an unmapped informational message; empty response on premium-only endpoints.

Common situations: Custom securities added by users; non-US symbols without the correct .LON/.DEX-style suffix; upstream response drift.

Related errors


AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21). Data as JSON: /api/errors/ba79a99ae6607d7c. Report an issue: GitHub.