Class: YahooFinance::Historical
- Inherits:
-
Object
- Object
- YahooFinance::Historical
- Includes:
- Enumerable
- Defined in:
- lib/yahoo_finance/historical.rb
Constant Summary collapse
- BASE_URL =
"http://ichart.finance.yahoo.com/table.csv"
- GROUPS =
{ :daily => "d", :weekly => "w", :monthly => "m" }
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
-
#ticker ⇒ Object
readonly
Returns the value of attribute ticker.
Class Method Summary collapse
- .daily(ticker, options = {}) ⇒ Object
- .monthly(ticker, options = {}) ⇒ Object
- .weekly(ticker, options = {}) ⇒ Object
Instance Method Summary collapse
- #each(&block) ⇒ Object
-
#initialize(ticker, options = {}) ⇒ Historical
constructor
A new instance of Historical.
- #to_csv ⇒ Object
Constructor Details
#initialize(ticker, options = {}) ⇒ Historical
Returns a new instance of Historical.
31 32 33 34 35 36 |
# File 'lib/yahoo_finance/historical.rb', line 31 def initialize(ticker, = {}) @ticker = ticker @start_date = [:from] @end_date = [:to] @group = [:group] || GROUPS[:daily] end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
9 10 11 |
# File 'lib/yahoo_finance/historical.rb', line 9 def end_date @end_date end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
9 10 11 |
# File 'lib/yahoo_finance/historical.rb', line 9 def group @group end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
9 10 11 |
# File 'lib/yahoo_finance/historical.rb', line 9 def start_date @start_date end |
#ticker ⇒ Object (readonly)
Returns the value of attribute ticker.
9 10 11 |
# File 'lib/yahoo_finance/historical.rb', line 9 def ticker @ticker end |
Class Method Details
.daily(ticker, options = {}) ⇒ Object
19 20 21 |
# File 'lib/yahoo_finance/historical.rb', line 19 def self.daily(ticker, = {}) new(ticker, .merge(:group => GROUPS[:daily])) end |
.monthly(ticker, options = {}) ⇒ Object
27 28 29 |
# File 'lib/yahoo_finance/historical.rb', line 27 def self.monthly(ticker, = {}) new(ticker, .merge(:group => GROUPS[:monthly])) end |
.weekly(ticker, options = {}) ⇒ Object
23 24 25 |
# File 'lib/yahoo_finance/historical.rb', line 23 def self.weekly(ticker, = {}) new(ticker, .merge(:group => GROUPS[:weekly])) end |
Instance Method Details
#each(&block) ⇒ Object
38 39 40 |
# File 'lib/yahoo_finance/historical.rb', line 38 def each(&block) result.reverse_each(&block) end |
#to_csv ⇒ Object
42 43 44 |
# File 'lib/yahoo_finance/historical.rb', line 42 def to_csv raw_data.lines.to_a[1..-1].join end |