No BSD License  

Highlights from
Maximum Drawdown

3.2

3.2 | 5 ratings Rate this file 31 Downloads (last 30 days) File Size: 1.09 KB File ID: #10367
image thumbnail

Maximum Drawdown

by Andreas Steiner

 

16 Mar 2006 (Updated 16 Mar 2006)

Calculates max drawdown, start/end of msx drawdown period, end of recovery period

| Watch this File

File Information
Description

Maximum drawdown can be defined as the largest drop from a peak to a bottom in a certain time period. This MATLAB function calculate max drawdown value, start and end of max drawdown period as well as the end of the recovery period (if any).

Acknowledgements
This submission has inspired the following:
Maximum Drawdown
MATLAB release MATLAB 7.0.4 (R14SP2)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
29 Dec 2006 juan jose fernandez

great and useful

31 Jul 2007 Andreas Bonelli

Calculating the maximum of all previous elements in each iteration is not necessary. You can store the previous maximum and simply calculate the maximum of two elements in every loop.

mx = 0;
for i = 1:n
    mx = max([lastmax, cr(i)]);
    dd(i) = mx - cr(i);
end;

This has a huge impact on the function's performance. (Complexity reduction from O(n^2) to O(n).)

Depending on the shape of the curve avoiding writing mx in each iteration should yield a significant speedup as well:

mx = 0;
for i = 1:n
    if cr(i) > mx mx = cr(i); end
    dd(i) = mx - cr(i);
end;

15 May 2008 Rick Jacobs

Max Drawdown is so easy to calculate in your head.

09 Jul 2008 Hae Kyung Im

Good, since it gets the job done. Just add Andreas Bonelli's efficiency improvement.

15 Sep 2008 Andy Bibombe  
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
finance Andreas Steiner 22 Oct 2008 08:18:41
modeling Andreas Steiner 22 Oct 2008 08:18:41
analysis Andreas Steiner 22 Oct 2008 08:18:41
maximum drawdown risk investment performance analysis Andreas Steiner 22 Oct 2008 08:18:41

Contact us at files@mathworks.com