dddf = pd.DataFrame(
  columns=['Drawdown', 'Start', 'End'])

dddf['Drawdown'] = ((vdf['Fund Total'].dropna() / np.maximum.accumulate(vdf['Fund Total'].dropna(), axis=0)) - 1)

is_zero = dddf['Drawdown'] == 0

dddf['Start'] = ~is_zero & is_zero.shift(1)
start = list(dddf[dddf['Start']].index)

dddf['End'] = is_zero & (~is_zero).shift(1)
end = list(dddf[dddf['End']].index)

if start[0] > end[0]:
	start.insert(0, dddf.index[0])

if start[-1] > end[-1]:

dd_vdf = pd.DataFrame(
  index=range(0, len(start)),
  columns=('Start', 'End', 'Length', 'Drawdown'))

for i in range(0, len(start)):
  dd = dddf[start[i]:end[i]]['Drawdown'].min()
  dd_vdf.iloc[i] = (start[i].strftime('%Y-%m-%d'), end[i].strftime('%Y-%m-%d'), (end[i] -start[i]).days, dd)
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter