Sha256: dd9b9a30be845f8da2fd9873d925659ed29716f0853dbd29de292d687a288080
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
module IEX module Endpoints module HistoricalPrices def historical_prices(symbol, options = {}) if options[:range] == 'date' raise ArgumentError unless options[:date] raise ArgumentError unless options[:chartByDay] end options = options.dup # Historical prices IEX endpoint expects dates passed in a specific format - YYYYMMDD options[:date] = options[:date].strftime('%Y%m%d') if options[:date].is_a?(Date) path = "stock/#{symbol}/chart" path += "/#{options[:range]}" if options.key?(:range) path += "/#{options[:date]}" if options[:range] == 'date' # We only want options to include query params at this point, remove :range and :date options.delete(:range) options.delete(:date) (get(path, { token: publishable_token }.merge(options)) || []).map do |data| IEX::Resources::HistorialPrices.new(data) end rescue Faraday::ResourceNotFound => e raise IEX::Errors::SymbolNotFoundError.new(symbol, e.response[:body]) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
iex-ruby-client-2.1.0 | lib/iex/endpoints/historial_prices.rb |
iex-ruby-client-2.0.0 | lib/iex/endpoints/historial_prices.rb |
iex-ruby-client-1.6.0 | lib/iex/endpoints/historial_prices.rb |