load_gains {stocks} | R Documentation |
Download and Align Gains for a Set of Tickers
Description
Downloads and aligns historical investment gains for specified tickers from Yahoo! Finance, using the quantmod package.
Usage
load_gains(tickers, intercepts = NULL, slopes = NULL, from = "1950-01-01",
to = Sys.Date(), time.scale = "daily", preto.days = NULL,
prefrom.days = NULL, earliest = FALSE, latest = FALSE)
Arguments
tickers |
Character vector with ticker symbols that Yahoo! Finance recognizes. |
intercepts |
Numeric vector of values to add to daily gains for each ticker. |
slopes |
Numeric vector of values to multiply daily gains for each ticker by. Slopes are multiplied prior to adding intercepts. |
from |
Date or character string (e.g. |
to |
Date or character string (e.g. |
time.scale |
Character string controlling time frame for gains. Choices
are |
preto.days |
Numeric value. If specified, function returns gains for
|
prefrom.days |
Numeric value. If specified, function returns gains for
|
earliest |
Logical value for whether to retain only the subset of
tickers with data going the furthest back. Set to |
latest |
Logical value for whether to retain only the subset of tickers with data going the furthest forward, e.g. dropping funds that were discontinued at some point. |
Details
In aligning historical prices, dates on which not all funds have data are simply dropped. Messages are printed indicating which dates are dropped for which tickers.
Value
Numeric matrix.
References
Ryan, J.A. and Ulrich, J.M. (2017) quantmod: Quantitative Financial Modelling Framework. R package version 0.4-12, https://CRAN.R-project.org/package=quantmod.
Examples
## Not run:
# Load gains for Netflix and Amazon over their mutual lifetimes
gains <- load_gains(c("NFLX", "AMZN"))
## End(Not run)