onemetric_overtime_graph: Graph Performance Metric Over Time for Various Investments

Description Usage Arguments Value References Examples

View source: R/onemetric_overtime_graph.R

Description

Useful for visualizing the performance of a group of investments over time. The first investment is used as the benchmark if the requested metric requires one.

Usage

1
2
3
4
5
onemetric_overtime_graph(tickers = NULL, ..., gains = NULL, prices = NULL,
  y.metric = "cagr", window.units = 50, add.plot = FALSE, colors = NULL,
  lty = NULL, plot.list = NULL, points.list = NULL, legend.list = NULL,
  pdf.list = NULL, bmp.list = NULL, jpeg.list = NULL, png.list = NULL,
  tiff.list = NULL)

Arguments

tickers

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.

gains

Numeric matrix with 1 column of gains for each investment (can be a vector if there is only one).

prices

Numeric matrix with 1 column of prices for each investment (can be a vector if there is only one).

y.metric

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.

window.units

Numeric value specifying the width of the moving window.

add.plot

Logical value for whether to add plot data to current plot frame rather than open a new one.

colors

Character vector of colors for each curve.

lty

Numeric vector specifying line types for each curve.

plot.list

List of arguments to pass to plot.

points.list

List of arguments to pass to points.

legend.list

List of arguments to pass to legend.

pdf.list

List of arguments to pass to pdf.

bmp.list

List of arguments to pass to bmp.

jpeg.list

List of arguments to pass to jpeg.

png.list

List of arguments to pass to png.

tiff.list

List of arguments to pass to tiff.

Value

In addition to the graph, a numeric matrix containing the performance metric over time for each investment.

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

1
2
3
4
5
6
7
## Not run: 
# Plot BRK-B's 50-day alpha over time since the start of 2016
fig <- onemetric_overtime_graph(tickers = c("VFINX", "BRK-B"), 
                                y.metric = "alpha", 
                                from = "2016-01-01")

## End(Not run)

vandomed/stocks documentation built on Sept. 2, 2018, 10:10 a.m.