Module: IEX::Resources::Chart

Defined in:
lib/iex/resources/chart.rb,
lib/iex/resources/chart/base.rb,
lib/iex/resources/chart/default.rb,
lib/iex/resources/chart/one_day.rb

Defined Under Namespace

Classes: Base, Default, OneDay

Class Method Summary collapse

Class Method Details

.get(stock_symbol, range = nil, options = {}) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/iex/resources/chart.rb', line 9

def self.get(stock_symbol, range = nil, options = {})
  IEX::Resources::Base.symbol(stock_symbol) do
    response = IEX::Api::Chart.get(stock_symbol, range, options)
    if range && range.to_s == 'dynamic'
      range = response['range']
      response = response['data']
    end
    response.map do |data|
      case range
      when '1d', Date, DateTime
        Chart::OneDay.new data
      else
        Chart::Default.new data
      end
    end
  end
end