Class: YahooFinance::StockHistory

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

Instance Method Summary collapse

Constructor Details

#initialize(stock, start_date, end_date = nil) ⇒ StockHistory

Returns a new instance of StockHistory.



284
285
286
287
288
289
290
291
292
# File 'lib/yahoo_finance/stock.rb', line 284

def initialize stock, start_date, end_date = nil
  @stock = stock
  @start_date = start_date
  if end_date
    @end_date = end_date
  else
    @end_date = Date.today - 1
  end    
end

Instance Method Details

#fetchObject



294
295
296
297
# File 'lib/yahoo_finance/stock.rb', line 294

def fetch
  ys = YahooStock::History.new(:stock_symbol => @stock, :start_date => @start_date, :end_date => @end_date)
  ys.results(:to_hash).output
end