metrics: Calculate Various Performance Metrics

Description Usage Arguments Value References Examples

View source: R/metrics.R

Description

Useful for comparing metrics for several investments. The first investment is used as the benchmark if requested metrics require one.

Usage

1
2
3
4
metrics(tickers = NULL, ..., gains = NULL, prices = NULL,
  perf.metrics = c("mean", "sd", "growth", "cagr", "mdd", "sharpe", "sortino",
  "alpha", "beta", "r.squared", "pearson", "spearman", "auto.pearson",
  "auto.spearman"))

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).

perf.metrics

Character vector specifying metrics to calculate.

Value

List containing:

  1. Numeric matrix named perf.metrics with performance metrics.

  2. Numeric matrix named cor.mat with correlation matrix for gains for the various investments.

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
## Not run: 
# Calculate performance metrics for SSO and UPRO, using SPY as benchmark 
# for alpha and beta
metrics1 <- metrics(tickers = c("SPY", "SSO", "UPRO"))

## End(Not run)

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