Open bbalouki opened 2 weeks ago
Same problem here...
I also encountered the same issue, the code was working fine previously but suddenly gives below error when I try to create a html report. Not sure if it coincide with recent yahoodownloader update, but hopefully a solution can be found soon
To fix the resampling issue in the quantstats library, locate the "core.py" file in the quantstats installation directory (usually found in your Python site-packages).
Around line 292, replace the existing code with the following:
if resample:
returns = returns.resample(resample)
returns = returns.last() if compound is True else returns.sum()
if isinstance(benchmark, _pd.Series):
benchmark = benchmark.resample(resample)
benchmark = benchmark.last() if compound is True else benchmark.sum()
I haven't tested the entire repo, but when I call full() it works. :)
It was issued by brunch in "Issues" https://github.com/ranaroussi/quantstats/pull/375.
Still there are some issues as below ../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1016: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
port["Weekly"].ffill(inplace=True) ../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1019: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
port["Monthly"].ffill(inplace=True) ../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1022: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
port["Quarterly"].ffill(inplace=True) ../miniforge3/envs/fin12/lib/python3.12/site-packages/quantstats/_plotting/core.py:1025: FutureWarning: A value is trying to be set on a copy of a DataFrame or Series through chained assignment using an inplace method. The behavior will change in pandas 3.0. This inplace method will never work because the intermediate object on which we are setting values always behaves as a copy.
For example, when doing 'df[col].method(value, inplace=True)', try using 'df.method({col: value}, inplace=True)' or df[col] = df[col].method(value) instead, to perform the operation inplace on the original object.
port["Yearly"].ffill(inplace=True)
qs.reports.full(returns, mode='full', benchmark=benchmark) File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats\reports.py", line 628, in full plots( File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats\reports.py", line 1346, in plots _plots.daily_returns( File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats_plotting\wrappers.py", line 512, in daily_returns fig = _core.plot_timeseries( File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\quantstats_plotting\core.py", line 294, in plot_timeseries returns = returns.last() if compound is True else returns.sum(axis=0) File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\pandas\core\resample.py", line 1183, in sum nv.validate_resampler_func("sum", args, kwargs) File "C:\ProgramData\miniconda3\envs\bbsdev\lib\site-packages\pandas\compat\numpy\function.py", line 376, in validate_resampler_func raise UnsupportedFunctionCall( pandas.errors.UnsupportedFunctionCall: numpy operations are not valid with resample. Use .resample(...).sum() instead