mdd: Maximum Drawdown

Description Usage Arguments Value Examples

View source: R/mdd.R

Description

Calculates maximum drawdown from vector of closing prices, highs and lows, or gains. Missing values should be removed prior to calling this function.

Usage

1
mdd(prices = NULL, highs = NULL, lows = NULL, gains = NULL, indices = FALSE)

Arguments

prices

Numeric vector of daily closing prices.

highs

Numeric vector of daily high prices.

lows

Numeric vector of daily low prices.

gains

Data frame with one column of gains for each investment (extra non-numeric columns are ignored), or numeric vector for one investment.

indices

Logical value for whether to include indices for when the maximum drawdown occurred.

Value

Numeric value, vector, or matrix depending on indices and whether there is 1 fund or several.

Examples

1
2
3
4
5
6
7
## Not run: 
# Calculate MDD's for FANG stocks in 2018
prices <- load_prices(c("FB", "AAPL", "NFLX", "GOOG"), from = "2018-01-01", 
                      to = "2018-12-31")
sapply(prices[-1], mdd)

## End(Not run)

vandomed/stocks documentation built on July 22, 2020, 3:25 a.m.