I have DataFrame final with returns of my portfolio. I am trying to calculate the MaxDrawdown using the returns. I have tried the below code and did see many stackexchange questions. But not able to solve this. Is there any way possible to calculate the maximum draw down using returns of the portfolio.
Returns
1/2/2009 0.030483579
1/5/2009 0.002872092
1/6/2009 0.01461333
1/7/2009 -0.032431836
1/8/2009 0.0055774
1/9/2009 -0.019844336
1/12/2009 -0.019705618
1/13/2009 0.001093185
1/14/2009 -0.032726765
1/15/2009 0.013635182
1/16/2009 0.009807648
1/20/2009 -0.044440252
1/21/2009 0.035156229
1/22/2009 -0.01460641
1/23/2009 0.007399468
1/26/2009 0.007910521
1/27/2009 0.007848472
1/28/2009 0.028944903
1/29/2009 -0.023816962
1/30/2009 -0.02550717
2/2/2009 -0.000292223
2/3/2009 0.020191091
2/4/2009 -7.93651E-06
2/5/2009 0.020070065
2/6/2009 0.026235957
2/9/2009 -0.001606124
2/10/2009 -0.03629415
2/11/2009 0.00248416
2/12/2009 0.001925152
2/13/2009 -0.00441840
Code:
cum_returns = (1 + final).cumprod()
drawdown = 1 - final.div(final.cummax())
Can anyone help me in solving this. Thanks!