Module: IEX::Api::Chart

Defined in:
lib/iex/api/chart.rb

Class Method Summary collapse

Class Method Details

.connection(symbol, range) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/iex/api/chart.rb', line 15

def self.connection(symbol, range)
  IEX::Api.default_connection [
    symbol,
    'chart',
    range && range.respond_to?(:strftime) ? "date/#{range.strftime('%Y%m%d')}" : range
  ].compact.join('/')
end

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



4
5
6
7
8
9
10
11
12
13
# File 'lib/iex/api/chart.rb', line 4

def self.get(symbol, range = nil, options = {})
  connection(symbol, range).get do |c|
    if options && options.any?
      options.each_pair do |k, v|
        k = k.to_s.split('_').map(&:capitalize).join.sub(/^[A-Z]/, &:downcase)
        c.params[k.to_sym] = v
      end
    end
  end.body
end