rrr: Risk-Return Ratio

Description Usage Arguments Value Examples

View source: R/rrr.R

Description

Calculates risk-return ratio, defined as growth rate divided by maximum drawdown.

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# 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)

vandomed/stocks documentation built on Sept. 2, 2018, 10:10 a.m.