Open Side Menu Go to the Top
Register
Mathematical Definition or Algorithm of a Drawdown Mathematical Definition or Algorithm of a Drawdown

10-31-2007 , 09:31 PM
Given m real numbers {1 ... n} please provide a formula or algorithm to find the largest "drawdown." I'm having trouble formulating into words exactly what a drawdown is, but I have illustrated it in the below graph. A poor definition of "drawdown" would be "The distance between and peak and the lowest subsequent valley." The biggest drawdown in this graph is A-B, or (A-B)/A percent.

Edit: Right after I posted this I came up with an algorithm, but there may be more efficient versions. I'm interested in how you guys approach this.

Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 09:55 PM
Drawdown

= max [ sum[r(t)] ] - r(t)
t = 0..T


Maximum Loss

Given a time series with N log returns r(t) over t = 1 to T, we can define...

= min [r(1), r(1)+r(2), r(1)+r(2)+r(3), ..., r(1)+...+r(N)]

= min [ sum [r(i)] ]
t=0..N i=1..t

In words: The minimum cumulated return from the beginning in a certain time period.

Maximum Drawdown

The maximum drawdown can be loosely defined as the largest drop from a peak to a bottom in a certain time period.

Maximum drawdown captures a path-dependant feature of a time series which is not represented in the histogram of the return time series.

= min [r(1), r(1)+r(2), r(1)+r(2)+r(3), ..., r(1)+...+r(N),
r(2), r(2)+r(3), r(2)+r(3)+r(4), ..., r(2)+...+r(N), ..., r(N)]

= min [ sum [r(j)] ]
i=1..t, t=1..N j=i..t

In words: The minimum cumulated return from any beginning points over a certain time period.

= max [ Drawdown(t) ]
t=0..T

...the last formula yields the end-point of the maximum
drawdown period. The starting point is found at the
last time point Drawdown(t) was equal to zero.

Maximum drawdown is always smaller than or equal to the difference between maximum loss and maximum gain.

Maximum loss & gain are the global extreme values, maximum drawdown is a concept base on the local minimum of a return time series.

Maximum drawdown is often used when not enough observations are available to calculate volatility measures (like for example standard deviation).

Maximum drawdown is highly dependent on the time interval chosen (annual, monthly, daily and so on) as well as the observation period.


Source ---> http://www.andreassteiner.net/performanceanalysis/?Risk_Measurement:Absolute_Riskrawdown
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 10:00 PM
There's no formula for this since the data could be anything. All you can do is traverse the dataset looking at two items at a time.

Is this going to be written in code? If so, here's a sample algorithm in c (completely untested):
<font class="small">Code:</font><hr /><pre>
double[] d; // contains an array of the data

double currentlowest = 0;
double currenthighest = 0;
int largestdrawdownstartindex = 0;
int largestdrawdownendindex = 0;
int currentdrawdownstartindex = 0;
int currentdrawdownlowestindex = 0;
double largestdrawdownheight = 0;

for(int i = 0; i&lt;d.length;++i) // loop through each element of the data
{
// If data is higher than or equal to our current highest point, we either have a continuing upward trend or the end of a drawdown.
if(data[i] &gt;= currenthighest)
{
if(lowest &lt; currenthighest)
{
int drawdownheight = currenthighest - currentlowest;

// If biggest drawdown, save details
if(drawdownheight &gt; largestdrawdownheight)
{
largestdrawdownheight = drawdownheight;
largestdrawdownstartindex = currendrawdownstartindex;
largestdrawdownendindex = currentdrawdownlowestindex;
}
}
// reset values

currenthighest = data[i];
currentdrawdownstartindex = i;
currentlowest= data[i];
currentdrawdownlowestindex = i;

}
if(data[i] =&lt; currentlowest) {
currentlowest = data[i]};
currentdrawdownlowestindex = i;
}
}

</pre><hr />

The are no really useful optimizations that I can think of (at least starting with a dataset) since any single point can destroy the drawdown.
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 10:18 PM
So, given a_0...a_n, you're looking for the monotonically decreasing subsequence a_i...a_j such that (a_j - a_i) is a maximum?

If that's problem, you just need one iteration through the array, looking for contiguous decreasing subsequences as you go and remember the one that had the biggest "drawdown."

If you're trying to find a not necessarily monotonic subsequence that approximates the most visually striking "drawdown"...that is quite a bit harder, and probably requires heuristics.
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 10:22 PM
Yeah, I was thinking of a similar algorithm in log(n) time. Looks like it is the most efficient. Thanks for the help.
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 10:25 PM
Quote:
So, given a_0...a_n, you're looking for the monotonically decreasing subsequence a_i...a_j such that (a_j - a_i) is a maximum?

You got it. It's the math language I was missing. I really should have taken more algorithms classes in college, it really is a fascinating subject and I believe helps you think outside the box.
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 10:45 PM
Quote:
Quote:
So, given a_0...a_n, you're looking for the monotonically decreasing subsequence a_i...a_j such that (a_j - a_i) is a maximum?

You got it. It's the math language I was missing. I really should have taken more algorithms classes in college, it really is a fascinating subject and I believe helps you think outside the box.
From your graph, A to B is not monotonically decreasing.
Mathematical Definition or Algorithm of a Drawdown Quote
10-31-2007 , 11:00 PM
Define b_j = max(a_1,...,a_j) - a_j. The biggest drawdown is max(b_1,...,b_n).
Mathematical Definition or Algorithm of a Drawdown Quote
11-01-2007 , 10:59 PM
There's a formula out there something.
Look up Markov processes.
For losing players it's the entire bankroll.
Mathematical Definition or Algorithm of a Drawdown Quote

      
m