Description Usage Arguments Value Examples
Mainly a helper function for calc_metrics
and
calc_metrics_overtime
, but could also be used independently.
1 | calc_metric(gains, metric = "mean", units.year = 252, benchmark.gains = NULL)
|
gains |
Numeric vector. |
metric |
Character string specifying metric to calculate. Choices are
|
units.year |
Integer value. |
benchmark.gains |
Numeric vector. |
Numeric value.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ## Not run:
# Load daily gains for SPY in 2019 and calculate various metrics
gains <- load_gains(tickers = "SPY", from = "2019-01-01", to = "2019-12-31")
calc_metric(gains$SPY, "growth")
calc_metric(gains$SPY, "cagr")
calc_metric(gains$SPY, "mdd")
calc_metric(gains$SPY, "sharpe")
calc_metric(gains$SPY, "growth.10k")
# Calculate alpha and beta for TLT in 2019, using SPY as a benchmark
gains <- load_gains(tickers = c("SPY", "TLT"), from = "2019-01-01", to = "2019-12-31")
calc_metric(gains = gains$TLT, metric = "alpha", benchmark.gains = gains$SPY)
calc_metric(gains = gains$TLT, metric = "beta", benchmark.gains = gains$SPY)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.