Class: YQuotes::Yahoo

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

Instance Method Summary collapse

Instance Method Details

#fetch_csv(ticker, start_date = nil, end_date = nil, period = 'd') ⇒ Object Also known as: get_csv, get_data

fetch_csv: fetch historical quotes in csv format



13
14
15
16
17
18
19
# File 'lib/yquotes/yahoo.rb', line 13

def fetch_csv(ticker, start_date=nil, end_date=nil, period='d')
  url = QUOTE_ENDPOINT + build_params(ticker, start_date, end_date, period)
  connection = open(url)
  data = CSV.parse(connection.read, :converters => :numeric)
  raise "Yahoo.fetch_csv unable to fetch data" unless data.is_a? Array
  return data
end