{"record":{"id":"52e728ff75e9c006","repo":"we-promise/sure","slug":"no-prices-found-for-security-symbol-on-date-d","errorCode":null,"errorMessage":"No prices found for security #{symbol} on date #{date}","messagePattern":"No prices found for security #(.+?) on date #(.+?)","errorType":"exception","errorClass":"Provider::AlphaVantage::InvalidSecurityPriceError","httpStatus":null,"severity":"error","filePath":"app/models/provider/alpha_vantage.rb","lineNumber":168,"sourceCode":"\n      SecurityInfo.new(\n        symbol: parsed[\"Symbol\"] || symbol,\n        name: name,\n        links: parsed[\"OfficialSite\"].presence,\n        logo_url: nil,\n        description: parsed[\"Description\"].presence,\n        kind: parsed[\"AssetType\"]&.downcase,\n        exchange_operating_mic: exchange_operating_mic\n      )\n    end\n  end\n\n  def fetch_security_price(symbol:, exchange_operating_mic: nil, date:)\n    with_provider_response do\n      historical_data = fetch_security_prices(symbol:, exchange_operating_mic:, start_date: date, end_date: date)\n\n      raise historical_data.error if historical_data.error.present?\n      raise InvalidSecurityPriceError, \"No prices found for security #{symbol} on date #{date}\" if historical_data.data.blank?\n\n      historical_data.data.first\n    end\n  end\n\n  def fetch_security_prices(symbol:, exchange_operating_mic: nil, start_date:, end_date:)\n    with_provider_response do\n      av_symbol = to_av_symbol(symbol, exchange_operating_mic)\n\n      throttle_request\n      response = client.get(\"#{base_url}/query\") do |req|\n        req.params[\"function\"] = \"TIME_SERIES_DAILY\"\n        req.params[\"symbol\"] = av_symbol\n        req.params[\"outputsize\"] = \"compact\"\n      end\n\n      parsed = JSON.parse(response.body)\n      check_api_error!(parsed)","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/alpha_vantage.rb#L150-L186","documentation":"Provider::AlphaVantage#fetch_security_price raises InvalidSecurityPriceError when the date-ranged TIME_SERIES_DAILY query returns no rows for the requested symbol/date. Free-tier 'compact' output covers only ~100 trading days (~140 calendar days), so older dates return nothing; weekends/holidays and delisted symbols also yield empty data.","triggerScenarios":"fetch_security_price with a date older than ~140 days; a weekend/holiday date with no trading row; a symbol AV has no series for; date outside the returned window after filtering.","commonSituations":"Backfilling historical prices on the free tier; asking for the most recent date when markets were closed; invalid ticker.","solutions":["Request a recent trading day, or fall back to the last available price within an acceptable window.","For history older than ~140 days, use the full/paid tier or a different provider.","Check that the date is a trading day (skip Sat/Sun and the exchange's holidays).","Rescue InvalidSecurityPriceError and degrade gracefully (e.g. mark value as unavailable instead of crashing a sync)."],"exampleFix":"# before\nprice = provider.fetch_security_price(symbol: symbol, date: date)\n\n# after\nbegin\n  price = provider.fetch_security_price(symbol: symbol, date: date)\nrescue Provider::AlphaVantage::InvalidSecurityPriceError\n  price = nil # fall back to last known price or skip\nend","handlingStrategy":"fallback","validationCode":"date >= 140.days.ago.to_date && date.on_weekday? # free-tier compact window heuristic","typeGuard":null,"tryCatchPattern":"begin\n  provider.fetch_security_price(symbol: s, date: d)\nrescue Provider::AlphaVantage::InvalidSecurityPriceError\n  prices = provider.fetch_security_prices(symbol: s, start_date: d - 7, end_date: d).data\n  prices.last # fall back to the nearest earlier trading day\nend","preventionTips":["Only request dates inside the ~140-day compact window on free tier.","Skip weekends/holidays or fall back to the previous trading day.","Cache daily prices so each symbol costs one request per day."],"tags":["alpha-vantage","provider","prices","ruby"],"backgroundTag":"price-not-available-for-date","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}