code: def get_max_drawdown_underwater(underwater):
      
  
      valley = np.argmin(underwater)  # end of the period
      # Find first 0
      peak = underwater[:valley][underwater[:valley] == 0].index[-1]
      # Find last 0
      try:
          recovery = underwater[valley:][underwater[valley:] == 0].index[0]
      except IndexError:
          recovery = np.nan  # drawdown not recovered
      return peak, valley, recovery
docs: Determines peak, valley, and recovery dates given an 'underwater'
      DataFrame.
  
      An underwater DataFrame is a DataFrame that has precomputed
      rolling drawdown.
  
      Parameters
      ----------
      underwater : pd.Series
         Underwater returns (rolling drawdown) of a strategy.
  
      Returns
      -------
      peak : datetime
          The maximum drawdown's peak.
      valley : datetime
          The maximum drawdown's valley.
      recovery : datetime
          The maximum drawdown's recovery.