Measuring Maximum Drawdown and it’s Python Implementation .

Neelakash Chatterjee
Cloudcraftz
Published in
4 min readFeb 28, 2022

So, I’m back readers with our finance series . Today we are going to explore Maximum Drawdown — But what is that now ? We’ve already seen what volatility is , but if you haven’t please find it here . But before we begin we need to know , why do we at all need to know what Maximum Drawdown is ?

Lets see an example :

Asset A loses 1% a month for 12 months and Asset B gains 1% per month for 12 months. Which is the more volatile asset?

Answer - Neither. Since they both produce the same return each month, their deviations from their mean is zero each month, and so the volatility of both of these assets is 0.

So, we understand that Volatility itself is not enough to understand the risk associated with an asset , Asset A though loses money every month has a volatility of 0 and Asset B which produces a return of 1% also has a volatility of 0 . It’s only obvious that nobody would like to invest in an asset that loses money . This is where Maximum Drawdown comes into the picture .

What is Maximum Drawdown ?

Max Drawdown — The worst possible return one could see, if they had bought high and sold low. Which in other words is that, the return one would get when he/she buys an asset at its peak value and sells it when it is at its trough or the lowest possible value. In other words, Maximum drawdown measures the maximum fall in the value of the investment, as given by the difference between the value of the lowest trough and that of the highest peak before the trough.

How to Calculate Maximum Drawdown ?

Calculating a drawdown:

1) Take a return series and covert it to a wealth-index. A wealth index is just investing in an asset and hold it for a given period. Just invest and hold. Now for the time that you hold an asset, its value goes up and down and again up and so on. A drawdown is from the peak to the trough at any given point in time, the time for which you’re holding that particular asset for.

2) The next step is to compute the peaks, the previous peaks. We do this to keep track of the highest value our asset had since the time we invested in it. And since we are holding it, then again the market falls and its value reduces but our previous peak remains the same, now this difference between the peak value and any value that the asset possesses at any given point in time before we encounter another peak greater than the previous peak is what is known as the drawdown. (Image Below — The distance between the green and the blue lines is what we just said is our drawdown.)

Example of Maximum Drawdown:

Assume an investment portfolio has an initial value of $500,000. The portfolio increases to $750,000 over a period of time, before plunging to $400,000 in a ferocious bear market. It then rebounds to $600,000, before dropping again to $350,000.

Calculation of Maximum Drawdown :

The maximum drawdown in this case is

($350,000-$750000/$750,000) * 100 = -53.33%

For the above example , the peak appears at $750,000 and the trough appears at $350,000 . So, the Maximum Drawdown for the above time span is -53.33% .

Max Drawdown (Google Images)

Disadvantages of Maximum Drawdown

Disadvantages of Drawdown Measure:

1) Essentially dependent on 2 data points.

2) Drawdown on a daily basis is very different from monthly basis that is it is very sensitive to the granularity of the data. Drawdown on a daily basis will show us the worst case, whereas a monthly drawdown will show much less severity and a yearly basis even lesser.

Let’s see how to calculate the Max. Drawdown using a sample data of NIFTY . (Considering our Asset as NIFTY)

Python Implementation

Max Drawdown Python Function

This is a very simple python function that takes the DataFrame containing the close prices of our asset i.e. NIFTY (you may consider any stock, bond etc.) and the window size i.e. is the period for which we want the Maximum Drawdown as arguments, (here we did it for a year 252 Trading Days) and returns the daily drawdown. Try it out for various time durations (monthly, weekly etc.) , plot it and see the difference .

Note: There are 22 Trading days in a month and 5 Trading days in a week .

I hope you’re enjoying this finance series, people who want to trade or get started with trading may also keep these tools and techniques at their disposal . I’m sure it’ll help them make a much better decision .

Thank you readers, and I’ll be back with something different the next time . See ya !!

Credits: (Who helped me in creating this article)
1. Nabojyoti Pandey (My colleague at Cloudcraftz Solutions Pvt. Ltd.)
2. Amrit Kumar Sarkar (My colleague at Cloudcraftz Solutions Pvt. Ltd.)

--

--

Neelakash Chatterjee
Cloudcraftz

Senior Associate @Morgan Stanley | Data Scientist @NX Block Trades | Ex-Juniour Data Scientist @Cloudcraftz Solutions | https://www.linkedin.com/in/neelakash-c