Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Calculation of max draw down

How is the max draw down calculated?

In order to fairly evaluate risk in a trading system, I would prefer if this calculation is based off unrealized losses while in a trade. An example would be, "maximum account value peak to unrealized loss (while in a trade)", rather than only account value peak to lowest realized account value (completed trade). If this is not the case, how could this be implemented?

Thank you for the clarification.

3 responses

Any ideas on calculating max draw down to unrealized loss?

The built in portfolio max drawdown method does look at both realized and unrealized gains of the portfolio. It should do what you want. Maybe check this post https://www.quantopian.com/posts/calculation-of-cumulative-max-drawdown. Here is also the actual implementation https://github.com/quantopian/empyrical/blob/master/empyrical/stats.py .

I've attached a simple algorithm to demonstrate this. It simply buys and holds SPY and never sells. There are never any realized gains. Notice however the algorithm does track drawdown.

The built in max drawdown factor (https://www.quantopian.com/help#built-in-factors) just calculates based upon whatever series of inputs one gives it. Typically this is just daily returns based upon price and are also therefore 'unrealized'.

Appreciate if someone can fix this up to match the UI drawdown. Notes in the code.