twometrics_graph: Graph One Performance Metric vs. Another

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Create plot showing one performance metric vs. another for several investments.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
twometrics.graph(tickers = NULL, ...,
                 gains = NULL,
                 prices = NULL,
                 x.metric = "mdd",
                 y.metric = "cagr",
                 tickerlabel.offsets = NULL,
                 add.plot = FALSE,
                 colors = NULL,
                 plot.list = NULL,
                 points.list = NULL,
                 text.list = NULL,
                 pdf.list = NULL,
                 bmp.list = NULL,
                 jpeg.list = NULL,
                 png.list = NULL,
                 tiff.list = NULL)

Arguments

tickers

Character vector of ticker symbols. If x.metric or y.metric requires one benchmark index (i.e. one or the other is "alpha", "beta", "r.squared", "pearson", or "spearman"), the first ticker is taken to be the benchmark; if x.metric and y.metric require different benchmark indexes (i.e. one is "alpha", "beta", "r.squared", "pearson", or "spearman", and the other is "alpha2", "beta2", "r.squared2", "pearson2", or "spearman2"), the first ticker is taken to be the first benchmark, and the second ticker is taken to be the second benchmark.

...

Arguments to pass along with tickers to load.gains function, if you wish to load data on the fly rather than specify gains or prices.

gains

Numeric matrix of gains (daily or otherwise), where each column has gains for a particular investment. If x.metric or y.metric requires one benchmark index (i.e. one or the other is "alpha", "beta", "r.squared", "pearson", or "spearman"), the first column is taken to be the benchmark; if x.metric and y.metric require different benchmark indexes (i.e. one is "alpha", "beta", "r.squared", "pearson", or "spearman", and the other is "alpha2", "beta2", "r.squared2", "pearson2", or "spearman2"), the first column is taken to be the first benchmark, and the second column is taken to be the second benchmark.

prices

Numeric matrix of prices (daily or otherwise), where each column has prices for a particular investment. If x.metric or y.metric requires one benchmark index (i.e. one or the other is "alpha", "beta", "r.squared", "pearson", or "spearman"), the first column is taken to be the benchmark; if x.metric and y.metric require different benchmark indexes (i.e. one is "alpha", "beta", "r.squared", "pearson", or "spearman", and the other is "alpha2", "beta2", "r.squared2", "pearson2", or "spearman2"), the first column is taken to be the first benchmark, and the second column is taken to be the second benchmark.

x.metric

Character string specifying what performance metric should be plotted on x-axis. Possible values are as follows: "mean" for mean of gains; "sd" for standard deviation of gains; "growth" for total growth; "cagr" for compound annualized growth rate; "mdd" for maximum drawdown; "sharpe" for Sharpe ratio; "sortino" for Sortino ratio; "alpha" or "beta" for alpha and beta from capital assets pricing model theory; "r.squared" for R-squared from regression on benchmark fund; "pearson" or "spearman" for Pearson or Spearman correlation with benchmark fund; "alpha2", "beta2", "r.squared2", "pearson2", or "spearman2" for same as previously described, but using the second benchmark index; or "auto.pearson" or "auto.spearman" for Pearson or Spearman autocorrelation, defined as the correlation between subsequent gains.

y.metric

Same as x.metric, but for y-axis variable.

tickerlabel.offsets

Can be any of the following: numeric vector of length 2 giving x-axis and y-axis offsets for ticker labels on all data points; 2-column matrix where each row gives x-axis offset and y-axis offset for a particular ticker, following same order of tickers as in tickers vector; or a 3-column data frame where each row contains a ticker symbol, an x-axis offset, and a y-axis offset.

add.plot

If TRUE, data is plotted on current plot frame rather than a new one.

colors

Character string of colors for each fund.

plot.list

Optional list of inputs to pass to plot function.

points.list

Optional list of inputs to pass to points function.

text.list

Optional list of inputs to pass to text function.

pdf.list

Optional list of inputs to pass to pdf function. If not NULL, .pdf file is created.

bmp.list

Optional list of inputs to pass to bmp function. If not NULL, .bmp file is created.

jpeg.list

Optional list of inputs to pass to pdf function. If not NULL, .jpg file is created.

png.list

Optional list of inputs to pass to png function. If not NULL, .png file is created.

tiff.list

Optional list of inputs to pass to tiff function. If not NULL, .tif file is created.

Details

If tickers is specified, it gets passed to load.gains to load historical prices from Yahoo! Finance using the quantmod package [1]. If gains or prices is specified, the performance metrics are calculated directly from that information.

Value

In addition to the graph, a data frame containing the tickers and the performance metrics for each ticker.

Note

NA

Author(s)

Dane R. Van Domelen

References

1. Jeffrey A. Ryan (2016). quantmod: Quantitative Financial Modelling Framework. R package version 0.4-6, https://cran.r-project.org/package=quantmod.

Acknowledgment: This material is based upon work supported by the National Science Foundation Graduate Research Fellowship under Grant No. DGE-0940903.

See Also

onemetric.graph, onemetric.overtime.graph

Examples

1

Example output

Loading required package: rbenchmark
[1] NA

stocks documentation built on May 2, 2019, 5:22 p.m.