rrr {stocks} | R Documentation |
Risk-Return Ratio
Description
Calculates risk-return ratio, defined as growth rate divided by maximum drawdown.
Usage
rrr(prices = NULL, gains = NULL)
Arguments
prices |
Numeric matrix with 1 column of prices for each investment (can be a vector if there is only one). |
gains |
Numeric matrix with 1 column of gains for each investment (can be a vector if there is only one). |
Value
Numeric value or vector.
Examples
# Simulate daily gains over a 5-year period
set.seed(123)
stock.gains <- rnorm(252 * 5, 0.0005, 0.01)
# Convert to daily balances assuming an initial balance of $10,000
daily.balances <- gains_prices(stock.gains + 1)
# Total return is about 1.23
daily.balances[length(daily.balances)] / daily.balances[1] - 1
# Maximum drawdown is about 0.19
mdd(prices = daily.balances)
# Ratio of these two is about 6.48
(daily.balances[length(daily.balances)] / daily.balances[1] - 1) /
mdd(daily.balances)
# Easier to calculate using rrr function
rrr(daily.balances)
[Package stocks version 1.1.4 Index]