You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The get_top_drawdowns function in timeseries.py sometimes returns overlapping drawdown periods, which should not happen. This code reproduces the issue:
import pyfolio as pf
stock_rets = pf.utils.get_symbol_rets('FB')
pf.timeseries.gen_drawdown_table(stock_rets)
which produces the following output:
Drawdown with index 6 starts on 2014-10-24, finishes on 2015-01-15
Drawdown with index 5 starts on 2014-10-28, which cannot be a peak as then it would have meant the end of the previous drawdown.
the actual peak is getting removed from the series, allowing a subsequent drawdown to engulf the one that just got cropped. The cropping should start on the index immediately after peak. Assuming that indexes are always day-based replacing line 771 by
Partially related to this, lines 770-772 seem like a rather inefficient way of removing data from the series, an overall more efficient way would be to directly drop the unneeded lines rather than chop and concat:
The
get_top_drawdowns
function intimeseries.py
sometimes returns overlapping drawdown periods, which should not happen. This code reproduces the issue:which produces the following output:
Drawdown with index 6 starts on 2014-10-24, finishes on 2015-01-15
Drawdown with index 5 starts on 2014-10-28, which cannot be a peak as then it would have meant the end of the previous drawdown.
Problem occurs on
timeseries.py
lines 770-772:the actual peak is getting removed from the series, allowing a subsequent drawdown to engulf the one that just got cropped. The cropping should start on the index immediately after
peak
. Assuming that indexes are always day-based replacing line 771 byseems to fix the bug.
The text was updated successfully, but these errors were encountered: