rrr {stocks} | R Documentation |
Calculate ratio of investment return to investment risk based on a vector of prices or gains. The formula is growth rate / mdd, where growth rate is the growth of an investment over some time period and mdd is the maximum drawdown over that time period.
rrr(prices = NULL, gains = NULL, highs = NULL, lows = NULL, nas = FALSE)
prices |
Numeric vector of investment prices (typically daily closing prices). |
gains |
Numeric vector of gains. |
highs |
Numeric vector of daily highs. |
lows |
Numeric vector of daily lows. |
nas |
If |
Numeric value indicating the risk-return ratio.
Dane R. Van Domelen
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
, mdd
,
sharpe.ratio
, sortino.ratio
# Randomly generate daily stock 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 <- balances(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(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)