Module: BrmFinance

Defined in:
lib/brm_finance/stock.rb,
lib/brm_finance/version.rb

Defined Under Namespace

Classes: Stock

Constant Summary collapse

VERSION =
"1.0.13"

Class Method Summary collapse

Class Method Details

.dividends_splits(symbol, start_date = Date.today-1.year, end_date = Date.today) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/brm_finance/stock.rb', line 8

def BrmFinance.dividends_splits(symbol, start_date=Date.today-1.year, end_date=Date.today)
  symbol = [symbol] unless symbol.is_a?(Array)

  #start_date = start_date.strftime('%m-%d-%Y').split('-')
  #start_date = "a=#{start_date[0]}&b=#{start_date[1]}&c=#{start_date[2]}"

  #end_date = end_date.strftime('%m-%d-%Y').split('-')
  #end_date = "d=#{end_date[0]}&e=#{end_date[1]}&f=#{end_date[2]}"

  results = []
  symbol.each do |s|
    #url = "http://ichart.finance.yahoo.com/x?s=#{s}&#{start_date}&#{end_date}&g=v&y=0&z=30000"
    url = "http://ichart.finance.yahoo.com/x?s=#{s}&g=v&y=0&z=30000"
    response = RestClient.get(url)
    results.push({'Symbol' => s, 'Series' => CSV.parse(response)})
  end
  results
end