getSymbols.SMIF: Get stock data (optimized)

Description Usage Arguments Details Value See Also Examples

Description

A custom wrapper for getSymbol calls. Switches between different sources depending on server status, and ticker classification. Negates need for local storage of price data between calls. Optimized to increase speed of subsequent calls dramatically.

Usage

1
getSymbols.SMIF(tickers, full = F, try.av = F, ret = T)

Arguments

tickers

Character; a string or a vector of strings specifying the data which is required

full

Logical; should function return "full" data? If TRUE: return data will be a list of OHLC objects. If FALSE: return data will be an xts of Adjusted/Close price data for each ticker. Defaults to FALSE

try.av

Logical; should program attempt to get data from Alpha Vantage? Defaults to FALSE (AV servers are currently slow compared to Google's)

ret

Logical; should results be returned to user. If FALSE returns tickers to user. Defaults to TRUE

Details

Uses tryCatch and global options to determine and store current server status for premium data provider Alpha Vantage. Retrieves data based on status of AV's server (if down, data is retrieved from Google). Retrieved data is stored in a private environment and returned. This makes subsequent calls to the function with the same or similar arguments practically instantaneous. full data currently unavailable for tickers which contain "RFR".

Value

Either a list of OHLC objects (if isTRUE(full)) or a xts of Adjusted price data for each ticker (if !isTRUE(full))

See Also

.getTo, .getFrom: used to determine date boundries for data retrieval

Other data retrieval functions: getHoldings.SMIF, getSectorETF, getStockInfo

Examples

1
2
3
4
## Not run: 
getSymbols.SMIF(c("NVDA", "SPY", "RFR"), full = FALSE) 
## End(Not run)
getSymbols.SMIF("SPY", ret = FALSE)

alec25/smif.package documentation built on May 22, 2019, 12:36 p.m.