Quant Memo
Coding/●●●●●

Maximum drawdown from a return series

Asked at Two Sigma, Citadel

Often you are handed periodic returns, not the equity curve itself. Given simple returns r1,r2,,rnr_1, r_2, \dots, r_n (as decimals, so 0.100.10 means +10%+10\%), the equity after period kk is the running product tk(1+rt)\prod_{t \le k}(1 + r_t). Find the maximum drawdown, the largest peak-to-trough fractional drop, of the equity curve those returns generate.

returns = [0.10, -0.20, 0.05, -0.30, 0.10]
-> 0.412         # peak 1.10 down to trough 0.6468

Return the maximum drawdown as a fraction, in O(n)O(n) time and O(1)O(1) space. Do not materialize the whole equity array.

Your answer

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

More Coding questions