Is it possible the max drawdown periods are giving the wrong dates as an output? For example see this:
Here I'm finding the max drawdown for the dot-com and great recession crashes for QQQ.
!pip install quantstats
# need to install arial font with matplotlib
import matplotlib.font_manager as fm
import matplotlib.pyplot as plt
# arial_path = '/content/drive/MyDrive/arial.ttf'
# fm.fontManager.addfont(arial_path) # Register the Arial font with Matplotlib
# plt.rcParams['font.family'] = 'Arial'
import yfinance as yf
df = yf.download('QQQ', start='2000-01-01', end='2020-01-01')
import quantstats as qs
qs.extend_pandas()
returns = df.Close.pct_change()
qs.reports.full(returns, "QQQ")
OUTPUT:
_[Worst 5 Drawdowns]
Start Valley End Days Max Drawdown 99% Max Drawdown
# start of drawdown period
start_draw_down = df[df.index == '2000-03-28']
# end of drawdown period
end_draw_down = df[df.index == '2016-09-02']
# double checking a date before end of drawdown period where close has already broken out of drawdown period
earlier_date_in_drawdown_period = df[df.index == '2016-08-30']
print(start_draw_down.Close)
print(end_draw_down.Close)
print(earlier_date_in_drawdown_period.Close)
OUTPUT:
Date
2000-03-28 114.75
Name: Close, dtype: float64
Date
2016-09-02 117.120003
Name: Close, dtype: float64
Date
2016-08-30 116.559998
Name: Close, dtype: float64
Note, the 2016-08-30 has already surpassed the close from the previous high water mark. Therefore the drawdown end date that quant stats is calculating appears erroneous. Thoughts? Maybe I'm missing something.
Opened by @BAMBAMGit as issue #354 on quantstats
Is it possible the max drawdown periods are giving the wrong dates as an output? For example see this:
Here I'm finding the max drawdown for the dot-com and great recession crashes for QQQ.
OUTPUT: _[Worst 5 Drawdowns]
Start Valley End Days Max Drawdown 99% Max Drawdown
1 2000-03-28 2002-10-09 2016-09-02 6003 -82.96 -80.06 2 2018-08-30 2018-12-24 2019-04-16 230 -23.16 -19.77 3 2019-05-06 2019-06-03 2019-07-02 58 -10.98 -8.98 4 2018-03-13 2018-04-02 2018-06-01 81 -10.67 -10.02 5 2000-01-24 2000-01-28 2000-02-02 10 -10.65 -7.27_
OUTPUT: Date 2000-03-28 114.75 Name: Close, dtype: float64 Date 2016-09-02 117.120003 Name: Close, dtype: float64 Date 2016-08-30 116.559998 Name: Close, dtype: float64
Note, the 2016-08-30 has already surpassed the close from the previous high water mark. Therefore the drawdown end date that quant stats is calculating appears erroneous. Thoughts? Maybe I'm missing something.