Repository navigation
Open
Description
Problem Description
valley is not being set to a timestamp in line 884 of timeseries.py
Please provide a minimal, self-contained, and reproducible example:
too complex to add code here, will try later and add as a follow up comment
Please provide the full traceback:
Traceback (most recent call last):
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3441, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-2-535ebec2a3b4>", line 1, in <module>
runfile('/opt/fin_gpu/GPU_Podracer/test.py', wdir='/opt/fin_gpu/GPU_Podracer')
File "/opt/pycharm-2021.2.2/plugins/python/helpers/pydev/_pydev_bundle/pydev_umd.py", line 198, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/opt/pycharm-2021.2.2/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/opt/fin_gpu/GPU_Podracer/test.py", line 23, in <module>
args.env.backtest_plot(prediction, baseline_ticker = '^DJI', baseline_start = '2019-01-01', baseline_end = '2021-01-01')
File "/opt/fin_gpu/GPU_Podracer/elegant_finrl/env.py", line 291, in backtest_plot
pyfolio.create_full_tear_sheet(returns=test_returns, benchmark_rets=baseline_returns, set_context=False)
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/pyfolio/tears.py", line 173, in create_full_tear_sheet
create_returns_tear_sheet(
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/pyfolio/plotting.py", line 54, in call_w_context
return func(*args, **kwargs)
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/pyfolio/tears.py", line 457, in create_returns_tear_sheet
plotting.show_worst_drawdown_periods(returns)
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/pyfolio/plotting.py", line 1688, in show_worst_drawdown_periods
drawdown_df = timeseries.gen_drawdown_table(returns, top=top)
File "/home/guilherme/anaconda3/envs/GPU_Podracer/lib/python3.9/site-packages/pyfolio/timeseries.py", line 999, in gen_drawdown_table
df_drawdowns.loc[i, 'Valley date'] = (valley.to_pydatetime()
AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime'Please provide any additional information below:
Fixed the issue by replacing line 884 of timeseries.py with:
valley = underwater.index[np.argmin(underwater)] # end of the period
Versions
- Pyfolio version: 0.8.0
- Python version: 3.9
- Pandas version: 1.3.3
- Matplotlib version: 3.4.3
Reacted by xunfeng191, Jayakumar Munuswamy, Geri Leka, Yasuhiro Fujita and NovaLand
Reacted by Geri Leka
Metadata
Metadata
Assignees
Labels
No labels
Activity
[-]AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime' due to incorrect valley val format[/-][+]AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime' due to incorrect valley val type[/+]gerileka commentedon Apr 5, 2022
This resolved my issue, thank you