How Maximum Drawdown Is Calculated
Maximum drawdown is the largest percentage fall from a running peak in an equity curve to the lowest point that follows it before a new peak is made. It is the one headline statistic that is path-dependent — shuffle the returns and it changes, whereas Sharpe and Sortino do not. That property is why it is the most behaviourally honest number in a backtest report: it approximates the worst experience the strategy would have put you through.
Educational material, not trading advice. Algorithmic crypto trading is high-risk and most retail algo traders lose money.
The calculation
Compute the running maximum of equity, express current equity as a fraction of it, and take the minimum. In pandas that is four lines and it is worth knowing by heart:
equity = (1 + returns).cumprod()
peak = equity.cummax()
drawdown = equity / peak - 1 # <= 0 everywhere
max_dd = drawdown.min() # the most negative value
Two conventions to fix explicitly. Sign: the series above is negative, so the maximum drawdown is its minimum; many reports quote the absolute value instead, and mixing the two makes comparisons nonsense. Base: dividing by peak gives a percentage of the high-water mark, which is the standard. Dividing by initial capital gives a different, smaller-looking number, and it is not comparable to anyone else’s figure.
A related caution: computing drawdown on a series of prices rather than equity is fine for an asset, but for a strategy you want equity after costs. Gross drawdown understates the real one, because the fees paid during a losing stretch deepen it.
The variants worth reporting
Depth alone is an incomplete description, and three companions make it much more useful.
Drawdown duration is how long the equity spent below its previous peak — from the peak to the recovery. It matters because tolerance is a function of time as much as depth: a fall that recovers within days is a different experience from an identical fall that takes a year to repair, even though both report the same maximum drawdown.
Time to recovery is the second half of that span, measured from the trough. Reporting it separately distinguishes a fast fall with a slow grind back from a slow bleed with a sharp bounce.
The drawdown distribution, not just its worst value. The maximum is a single observation and therefore the least statistically stable number in your report. The 90th percentile of the drawdown series, or the average of the worst several episodes, tells you what to expect routinely — which is more actionable than a single extreme.
# episodes: contiguous stretches where drawdown < 0
in_dd = drawdown < 0
episode = (in_dd != in_dd.shift()).cumsum()
depths = drawdown[in_dd].groupby(episode[in_dd]).min()
lengths = in_dd[in_dd].groupby(episode[in_dd]).size()
What the number hides
Maximum drawdown is an in-sample extreme, and extremes do not generalize. Your backtest’s worst episode is the worst thing that happened in one particular slice of history. The true distribution has a tail beyond it, so the honest reading of a reported maximum drawdown is “at least this bad”, never “this bad at most”. A live drawdown exceeding the backtest’s maximum is not evidence of a broken strategy on its own — it is a normal consequence of having sampled a finite history.
It scales with leverage and with sample length in ways that make naive comparison misleading. Longer samples contain more opportunities for a deep episode, so a strategy tested over five years will typically show a worse maximum drawdown than the same strategy tested over one, with no difference in quality. Compare drawdowns only across equal-length samples, or normalize by reporting drawdown per unit of volatility.
It says nothing about why the drawdown happened. A drawdown caused by many small losses in a row is a strategy performing as designed in an unfavourable stretch. A drawdown caused by one enormous loss is a risk-control failure. The number is identical; the diagnosis is not. Always look at the trade-level composition of the worst episode rather than only its depth.
It is affected by survivorship in the data. A dataset that quietly excludes assets that went to zero cannot produce the drawdowns those assets caused — see survivorship bias in crypto datasets. A suspiciously shallow maximum drawdown on a wide crypto universe is often a universe problem, not a risk-management triumph.
Why it’s the number that ends strategies
Drawdown is where a backtest meets a person. A curve you would happily hold through on a chart is one you abandon in month four of a real decline, because the abstract percentage has become money and the recovery has no visible end. Deciding in advance the maximum drawdown you will tolerate before halting converts an emotional decision into a rule set while calm, and that pre-commitment is itself a risk control — a point developed in position sizing and risk management basics.
It also functions as a monitoring signal. A live drawdown deeper or longer than anything in the validated history is weak evidence that conditions have changed rather than that you got unlucky, and it is the most common trigger for reassessing whether an edge still exists — see regime change and why strategies decay. The distinction between bad luck and decay is genuinely hard, which is why the threshold should be defined beforehand: after the fact, every drawdown feels like decay.
Reporting it honestly
A short checklist that makes a drawdown figure trustworthy:
- State the sign convention and the base (fraction of high-water mark).
- Compute it on net equity, after fees, spread, and slippage — see modelling transaction costs in a backtest.
- Report duration and recovery time next to depth.
- Report the worst several episodes, not only the worst one.
- Give the sample length, so the extreme can be judged in proportion.
- Report it per walk-forward window as well as overall — a maximum drawdown that appears in every out-of-sample window is a property of the strategy; one that appears in a single window is an event. See how walk-forward validation works.
The framing to keep: drawdown is not a measure of how bad a strategy is, it’s a measure of what holding it feels like. That makes it the number most worth being pessimistic about, because it is the one that determines whether you are still running the strategy when its edge, if it has one, finally shows up.