Closed XJTLUmedia closed 1 year ago
It seems what happened to yfinance happened to quantstats too If I running following code to obtain end_date and start_date in yfinance, I will got
def get_date_diff_days(start_date_str, minus_days): start_date = datetime.datetime.strptime(start_date_str, "%Y-%m-%d") timedelta = datetime.timedelta(days=minus_days) end_date = start_date - timedelta end_date_str = end_date.strftime("%Y-%m-%d") return end_date_str
this error comes from report.py pandas.core.arrays.datetimelike.InvalidComparison: 2023-04-01 00:00:00
today = df.index[-1] # _dt.today() metrics['MTD %'] = comp_func(df[df.index >= _dt(today.year, today.month, 1)]) * pct d = today - relativedelta(months=3) metrics['3M %'] = comp_func(df[df.index >= d]) * pct d = today - relativedelta(months=6) metrics['6M %'] = comp_func(df[df.index >= d]) * pct metrics['YTD %'] = comp_func(df[df.index >= _dt(today.year, 1, 1)]) * pct d = today - relativedelta(years=1) metrics['1Y %'] = comp_func(df[df.index >= d]) * pct d = today - relativedelta(months=35) metrics['3Y (ann.) %'] = _stats.cagr(df[df.index >= d], 0., compounded) * pct d = today - relativedelta(months=59) metrics['5Y (ann.) %'] = _stats.cagr(df[df.index >= d], 0., compounded) * pct d = today - relativedelta(years=10) metrics['10Y (ann.) %'] = _stats.cagr(df[df.index >= d], 0., compounded) * pct
this part
Did you ever solve this? I see the error also
It seems what happened to yfinance happened to quantstats too If I running following code to obtain end_date and start_date in yfinance, I will got
this error comes from report.py pandas.core.arrays.datetimelike.InvalidComparison: 2023-04-01 00:00:00
this part