Premium problem164. Maximum Drawdown with Peak and Trough

Medium Locked

Given a 1-D array of periodic simple returns, return (max_dd, peak_idx, trough_idx):

  • build the equity curve cumprod(1 + r)
  • max_dd is the most negative value of equity / running_max - 1
  • peak_idx and trough_idx locate that drawdown's peak and trough

Input

[ 0.1  -0.2  -0.1   0.05  0.3 ]

Output

(-0.2799999999999999, 0, 2)

Premium problem

This one's part of Premium. Unlock the full NumPy track plus every other premium problem on the site.

Implement solve(...)