{"record":{"id":"a7fff9c5764eaa31","repo":"we-promise/sure","slug":"no-price-found-for-symbol-on-date","errorCode":null,"errorMessage":"No price found for #{symbol} on #{date}","messagePattern":"No price found for #(.+?) on #(.+?)","errorType":"exception","errorClass":"Provider::BinancePublic::InvalidSecurityPriceError","httpStatus":null,"severity":"warning","filePath":"app/models/provider/binance_public.rb","lineNumber":185,"sourceCode":"        logo_url: nil,\n        description: nil,\n        kind: \"crypto\",\n        exchange_operating_mic: exchange_operating_mic\n      )\n    end\n  end\n\n  def fetch_security_price(symbol:, exchange_operating_mic:, date:)\n    with_provider_response do\n      historical = fetch_security_prices(\n        symbol: symbol,\n        exchange_operating_mic: exchange_operating_mic,\n        start_date: date,\n        end_date: date\n      )\n\n      raise historical.error if historical.error.present?\n      raise InvalidSecurityPriceError, \"No price found for #{symbol} on #{date}\" if historical.data.blank?\n\n      historical.data.first\n    end\n  end\n\n  def fetch_security_prices(symbol:, exchange_operating_mic:, start_date:, end_date:)\n    with_provider_response do\n      parsed = parse_ticker(symbol)\n      raise InvalidSecurityPriceError, \"Unsupported Binance ticker: #{symbol}\" if parsed.nil?\n\n      if parsed[:stablecoin]\n        next stablecoin_prices(symbol, parsed, start_date, end_date, exchange_operating_mic)\n      end\n\n      binance_pair = parsed[:binance_pair]\n      display_currency = parsed[:display_currency]\n      prices = []\n      cursor = start_date","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/we-promise/sure/blob/e69894adb92547273377398c15f45c979cd9416a/app/models/provider/binance_public.rb#L167-L203","documentation":"Raised by Provider::BinancePublic#fetch_security_price (as InvalidSecurityPriceError, defined as Class.new(Error) at binance_public.rb:6) when fetch_security_prices for a single day succeeds but returns an empty data set. It can also re-raise historical.error first; this specific message fires only when historical.data.blank? for the requested date.","triggerScenarios":"Requesting a date before the pair was listed on Binance (e.g. a 2019 price for a 2021 coin); requesting a future date; a UTC day on which the pair had no kline data (extremely illiquid/delisted books); date boundary mismatches where the caller's timezone shifts the requested day outside available klines.","commonSituations":"Backfills that start from a portfolio creation date rather than the coin's listing date; securities whose created_at predates the actual listing; timezone handling passing local dates that resolve to empty UTC windows; retrying recently added coins whose history starts later than the account.","solutions":["Confirm the pair's listing date (first available kline on Binance) and clamp start_date to it.","Reject future dates before calling: no price can exist for date > Date.today.","If the price is genuinely missing, fall back to the nearest earlier close or the security's last known price rather than failing.","Rescue Provider::BinancePublic::InvalidSecurityPriceError per-date so one gap does not abort a range import."],"exampleFix":"# before\nprice = provider.fetch_security_price(symbol: \"BTCUSDT\", exchange_operating_mic: \"BINANCE\", date: Date.new(2015, 1, 1))\n\n# after\nbegin\n  price = provider.fetch_security_price(symbol: \"BTCUSDT\", exchange_operating_mic: \"BINANCE\", date: date)\nrescue Provider::BinancePublic::InvalidSecurityPriceError\n  price = nil # or last known close; skip the day instead of aborting the sync\nend","handlingStrategy":"fallback","validationCode":"return if date > Date.today # no price can exist in the future\nreturn if listing_date.present? && date < listing_date # before the pair traded","typeGuard":"def price_gap?(err)\n  err.is_a?(Provider::BinancePublic::InvalidSecurityPriceError) && err.message.start_with?(\"No price found\")\nend","tryCatchPattern":"begin\n  price = provider.fetch_security_price(symbol: sym, exchange_operating_mic: mic, date: date)\nrescue Provider::BinancePublic::InvalidSecurityPriceError\n  price = last_known_close_before(sym, date) # fall back to nearest earlier close\nend","preventionTips":["Clamp backfill start dates to the pair's Binance listing date.","Reject future dates before calling fetch_security_price.","Treat single-day gaps as data availability, not failure — fall back to the nearest earlier close.","Rescue per-date so one gap does not abort a range import."],"tags":["binance","historical-prices","empty-response","klines","crypto"],"backgroundTag":"no-historical-price","analyzedSha":"e69894adb92547273377398c15f45c979cd9416a","analyzedAt":"2026-08-21T18:22:41.165Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}