Quant Memo
Coding/●●●●●

Maximum drawdown, and report when it happened

Asked at Millennium, Point72

Reporting the size of the worst drawdown is rarely enough; risk teams want to know when it happened so they can attribute it to a specific event. Given an equity curve, return the maximum drawdown fraction together with the index of the peak it fell from and the index of the trough it fell to.

equity = [100, 120, 90, 105, 60, 80]
-> (0.5, 1, 4)         # 50% drop, from the peak at index 1 (120) to the trough at index 4 (60)

Return (mdd, peak_index, trough_index) in O(n)O(n) time and O(1)O(1) space.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions