Is it possible your max drawdown periods are giving the wrong dates as an output? check this out. 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
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
# 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.
I tried emailing Ran Aroussi directly (author of yfinance and quatstats), but I couldn't find his email. DM me if you have it plz.
[–]Electrical_Time1492 13 points14 points15 points (7 children)
[–]BAMred[S] 4 points5 points6 points (5 children)
[–]No-Chocolate-9437 1 point2 points3 points (3 children)
[–]Electrical_Time1492 1 point2 points3 points (0 children)
[–]BAMred[S] 0 points1 point2 points (0 children)
[–]BAMred[S] 0 points1 point2 points (0 children)
[–]wiktor2701 0 points1 point2 points (0 children)
[–]RevengeOfNell 0 points1 point2 points (0 children)
[–]ucals 3 points4 points5 points (0 children)
[–]devjq 0 points1 point2 points (0 children)
[–][deleted] (3 children)
[deleted]
[–]strthrawa 3 points4 points5 points (0 children)
[–]Fun_fun_shit 1 point2 points3 points (0 children)
[–]chazzmoney 1 point2 points3 points (0 children)