Class: YQuotes::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/yquotes.rb

Instance Method Summary collapse

Constructor Details

#initializeClient



11
12
13
# File 'lib/yquotes.rb', line 11

def initialize
  @yahoo_client = Yahoo.new
end

Instance Method Details

#get_quote(ticker, args = {}) ⇒ Object Also known as: historical_data, historical_quote

get_quote: returns Daru::DataFrame of the quote with volume and close



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/yquotes.rb', line 16

def get_quote(ticker, args = {})

  if args.is_a? Hash
    start_date = args[:start_date] if args[:start_date]
    start_date ||= args[:s] if args[:s]

    end_date = args[:end_date] if args[:end_date]
    end_date ||= args[:e] if args[:e]

    period = args[:period] if args[:period]
    period ||= args[:p] if args[:p]
  end

  csv = @yahoo_client.get_csv(ticker, start_date, end_date, period)
  create_from_csv(csv)
end