metrics {stocks}R Documentation

Calculate Various Performance Metrics

Description

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

Usage

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

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



[Package stocks version 1.1.4 Index]