Useful for visualizing the performance of a group of investments. The first investment is used as the benchmark if the requested metric requires one.
onemetric_graph(tickers = NULL, ..., gains = NULL, prices = NULL,
y.metric = "cagr", add.plot = FALSE, sort.tickers = TRUE,
plot.list = NULL, points.list = NULL, axis.list = NULL,
pdf.list = NULL, bmp.list = NULL, jpeg.list = NULL, png.list = NULL,
tiff.list = NULL)
Character vector of ticker symbols that Yahoo! Finance recognizes, if you want to download data on the fly.
Arguments to pass along with tickers
to
load_gains
.
Numeric matrix with 1 column of gains for each investment (can be a vector if there is only one).
Numeric matrix with 1 column of prices for each investment (can be a vector if there is only one).
Character string specifying y-axis performance metric. Choices are:
"mean"
or "sd"
for mean or standard deviation of gains.
"growth"
or "cagr"
for total or annualized growth.
"mdd"
for maximum drawdown.
"sharpe"
or "sortino"
for Sharpe or Sortino ratio.
"alpha"
, "beta"
, or "r.squared"
for those metrics from a
fitted linear regression on benchmark fund.
"pearson"
or "spearman"
for Pearson or Spearman correlation
with benchmark fund.
"auto.pearson"
or "auto.spearman"
for Pearson or Spearman
autocorrelation, defined as the correlation between subsequent gains.
Logical value for whether to add plot data to current plot frame rather than open a new one.
Logical value for whether to sort investments in decreasing order of the performance metric.
List of arguments to pass to plot
.
List of arguments to pass to
points
.
List of arguments to pass to axis
.
List of arguments to pass to pdf
.
List of arguments to pass to bmp
.
List of arguments to pass to jpeg
.
List of arguments to pass to png
.
List of arguments to pass to tiff
.
In addition to the graph, a data frame containing the performance metric for each investment.
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.
# NOT RUN {
# Compare annualized growth for VFINX, SSO, and UPRO
fig <- onemetric_graph(tickers = c("VFINX", "SSO", "UPRO"),
plot.list = list(ylim = c(0, 50)))
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab