Compute the drawdown of a time series.
drawdown(v, relative = TRUE, summary = TRUE)
a price series (a numeric vector)
if TRUE
, maximum drawdown is chosen according to percentage
losses; else in units of v
if TRUE
, provide maximum drawdown and time when it occured;
else return drawdown vector
If summary
is FALSE
, a vector of the same length as
v
. If summary
is TRUE
, a list
maximum drawdown
the max of v
position of high
the min of v
position of low
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.
Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance, Chapter 13. Elsevier. http://www.elsevierdirect.com/product.jsp?isbn=9780123756626
Schumann, E. (2016) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual
# NOT RUN {
v <- cumprod(1 + rnorm(20) * 0.02)
drawdown(v)
# }
Run the code above in your browser using DataLab