Learn R Programming

PMwR (version 1.0-1)

drawdowns: Compute Drawdowns

Description

Compute drawdown statistics.

Usage

drawdowns(x, ...)
# S3 method for default
drawdowns(x, ...)
# S3 method for zoo
drawdowns(x, ...)

Value

a data.frame:

peak

peak before drawdown

trough

lowest point

recover

new high or NA if the drawdown has not been recovered yet

max

the max drawdown

Arguments

x

a numeric vector of prices

...

additional arguments, to be passed to methods

Author

Enrico Schumann

Details

drawdowns is a generic function. It computes drawdown statistics: maximum; and time of peak, trough and recovery.

References

Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. tools:::Rd_expr_doi("10.1016/C2017-0-01621-X")

Schumann, E. (2023) Portfolio Management with R. https://enricoschumann.net/PMwR/;
in particular,
https://enricoschumann.net/R/packages/PMwR/manual/PMwR.html#drawdowns-streaks

See Also

The actual computation of the drawdowns is done by function drawdown in package NMOF.

Series of uninterrupted up and down movements can be computed with streaks.

Examples

Run this code
x <- c(100, 98)
drawdowns(x)

x <- c(100, 98, 102, 99)
dd <- drawdowns(x)
dd[order(dd$max, decreasing = TRUE), ]

Run the code above in your browser using DataLab