Class: PBYF
- Inherits:
-
Object
- Object
- PBYF
- Defined in:
- lib/pbyf.rb
Overview
Pause Break Yahoo Finance gem
Constant Summary collapse
- @@quote_url =
these are the base urls for querying various parts of yahoo finance
'http://download.finance.yahoo.com/d/quotes.csv?s='
- @@historical_quote_url =
'http://ichart.yahoo.com/table.csv?s='
Class Method Summary collapse
-
.get_hist_quote(str_of_stock, from_date, to_date, interval = 'd') ⇒ Object
one cannot get multiple stocks for historical quotes, you must get them separately for now dates will be assumed to be the format Month-Day-Year, i.e.
-
.get_quote(str_of_stocks, str_of_options) ⇒ Object
str_of_stocks should be formatted according to yahoo finance api docs.
Class Method Details
.get_hist_quote(str_of_stock, from_date, to_date, interval = 'd') ⇒ Object
one cannot get multiple stocks for historical quotes, you must get them separately for now dates will be assumed to be the format Month-Day-Year, i.e. 3-19-1988
25 26 27 28 29 30 31 32 |
# File 'lib/pbyf.rb', line 25 def self.get_hist_quote str_of_stock, from_date, to_date, interval = 'd' from = from_date.split('-') to = to_date.split('-') from_to_params = "&a=#{from[0].to_i-1}" + "&b=#{from[1]}" + "&c=#{from[2]}" + "&d=#{to[0].to_i-1}" + "&e=#{to[1]}" + "&f=#{to[2]}" query_url = @@historical_quote_url + str_of_stock + from_to_params + "&g=#{interval}" puts query_url arr_of_arrays = CSV.parse(RestClient.get query_url) end |
.get_quote(str_of_stocks, str_of_options) ⇒ Object
str_of_stocks should be formatted according to yahoo finance api docs
18 19 20 21 |
# File 'lib/pbyf.rb', line 18 def self.get_quote str_of_stocks, query_url = @@quote_url + str_of_stocks + '&f=' + arr_of_arrays = CSV.parse(RestClient.get query_url) end |