Description Usage Arguments Details Value Note Author(s) References See Also Examples
Calculates any or all of the following: mean and standard deviation of gains; total growth and compound annualized growth rate; maximum drawdown; Sharpe ratio and Sortino ratio; alpha, beta, Pearson correlation, and Spearman correlation, using first investment as the benchmark; and Pearson and Spearman autocorrelation, defined as the correlation between subsequent gains for each investment.
1 2 3 4 5 6 7 |
tickers |
Character vector of ticker symbols. |
... |
Arguments to pass along with tickers to |
gains |
Numeric matrix of gains (daily or otherwise), where each column has gains for a particular investment. |
prices |
Numeric matrix of prices (daily or otherwise), where each column has prices for a particular investment. |
perf.metrics |
Character vector indicating what metrics should be calculated. If it includes
|
If tickers input is specified, it gets passed to load.gains
to
load historical prices from Yahoo! Finance using the quantmod package
[1]. If gains
or prices
are specified, performance metrics are
calculated directly from that information.
A list containing a data frame with the performance metrics and a correlation matrix for gains for the various investments.
NA
Dane R. Van Domelen
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.
gains.rate
, prices.rate
, sharpe.ratio
,
sortino.ratio
, rrr
1 2 3 4 5 6 7 8 9 10 | # Calculate performance metrics for leveraged ETFs SSO and UPRO, using SPY
# as benchmark for alpha and beta - "on the fly" method
#metrics1 <- metrics(tickers = c("SPY", "SSO", "UPRO"))
# Calculate same performance metrics, but specify gains input
#gains <- load.gains(tickers = c("SPY", "SSO", "UPRO"))
#metrics2 <- metrics(gains = gains)
# Results are identical
#all(metrics1$perf.metrics == metrics2$perf.metrics)
|
Loading required package: rbenchmark
Loading required package: quantmod
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.