stefan-jansen / pyfolio-reloaded

Portfolio and risk analytics in Python
https://pyfolio.ml4trading.io/
Apache License 2.0
378 stars 110 forks source link

fix for inconsistencies in index for drawdown periods #10

Closed thlautenschlaeger closed 1 year ago

thlautenschlaeger commented 3 years ago

I am not able to reproduce it at the moment but in some cases the line valley = underwater.idxmin() assigns the integer position to valley instead of the datetime index. This assignment caused crashing when plotting the biggest drawdowns. The crash happened at:

 df_drawdowns.loc[i, 'Valley date'] = (valley.to_pydatetime()
                                              .strftime('%Y-%m-%d'))

in timeseries.py in the method: gen_drawdown_table()

MBounouar commented 3 years ago

Then my 2cents would be that your PR would just hide a potentially larger problem instead of resolving it. My first guess would be that either the problem is coming from a bug in a version of pandas (check which version you are using ?), or something weird is happening in the background. The original authors intended to deprecate all these functions in favor of the empyrical package functions. So it's not impossible that a few things have been overlooked.

stefan-jansen commented 1 year ago

Closing for now absent further activity.