Class: YQuotes::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(filter_zero_volume = true) ⇒ Client

Returns a new instance of Client.



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

def initialize(filter_zero_volume = true)
  @yahoo_client = Yahoo.new
  @filter_zero_volume = filter_zero_volume
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



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

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