Class: StockCruncher::AlphaVantage
- Defined in:
- lib/stockcruncher/alphavantage.rb
Overview
This is an data cruncher class for AlphaVantage API.
Constant Summary collapse
- API_URL =
'https://www.alphavantage.co/query?'
Instance Method Summary collapse
-
#crunch_daily(symbol, fullsize) ⇒ Object
Main method to crunch data.
-
#crunch_quote(symbol) ⇒ Object
Main method to crunch data.
- #parameters(symbol, serie) ⇒ Object
Methods inherited from Cruncher
Constructor Details
This class inherits a constructor from StockCruncher::Cruncher
Instance Method Details
#crunch_daily(symbol, fullsize) ⇒ Object
Main method to crunch data.
12 13 14 15 16 17 |
# File 'lib/stockcruncher/alphavantage.rb', line 12 def crunch_daily(symbol, fullsize) url = API_URL + parameters(symbol, 'TIME_SERIES_DAILY') url += '&datatype=csv&outputsize=' + (fullsize ? 'full' : 'compact') res = request(url) res.body end |
#crunch_quote(symbol) ⇒ Object
Main method to crunch data.
20 21 22 23 24 25 |
# File 'lib/stockcruncher/alphavantage.rb', line 20 def crunch_quote(symbol) url = API_URL + parameters(symbol, 'GLOBAL_QUOTE') url += '&datatype=csv' res = request(url) res.body end |
#parameters(symbol, serie) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/stockcruncher/alphavantage.rb', line 27 def parameters(symbol, serie) p = 'function=' + serie p += '&symbol=' + symbol p += '&apikey=' + @config[self.class.name.split('::').last]['apikey'] p end |