Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

drawdown

Drawdown


Description

Compute the drawdown of a time series.

Usage

drawdown(v, relative = TRUE, summary = TRUE)

Arguments

v

a price series (a numeric vector)

relative

if TRUE, maximum drawdown is chosen according to percentage losses; else in units of v

summary

if TRUE, provide maximum drawdown and time when it occured; else return drawdown vector

Details

The drawdown at position t of a time series v is the difference between the highest peak that was reached before t and the current value. If the current value represents a new high, the drawdown is zero.

Value

If summary is FALSE, a vector of the same length as v. If summary is TRUE, a list

maximum

maximum drawdown

high

the max of v

high.position

position of high

low

the min of v

low.position

position of low

Author(s)

Enrico Schumann

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. https://www.elsevier.com/books/numerical-methods-and-optimization-in-finance/gilli/978-0-12-815065-8

Schumann, E. (2019) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

Examples

v <- cumprod(1 + rnorm(20) * 0.02)
drawdown(v)

NMOF

Numerical Methods and Optimization in Finance

v2.4-1
GPL-3
Authors
Enrico Schumann [aut, cre] (<https://orcid.org/0000-0001-7601-6576>)
Initial release
2021-04-09

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.