Skip to content

AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime' #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mwahal opened this issue Jan 31, 2023 · 1 comment
Open

Comments

@mwahal
Copy link

mwahal commented Jan 31, 2023

Got the following error when running main.py

Launched the iteration with [3.54797493e+01 3.03116053e+01 3.33437532e-02 7.52396842e-01]
Starting Portfolio Value: 1000.00
Final Portfolio Value: 859.65
Performance:
Return: -14.035259200000086%
Stability:-0.40157739067589127
Top-5 Drawdowns:
Traceback (most recent call last):
File "main.py", line 44, in
xopt, fopt = pso(obj_fun, lb, ub, swarmsize=20, maxiter=40)
File "/home/wmudit/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pyswarm/pso.py", line 111, in pso
fp[i] = obj(p[i, :])
File "/home/wmudit/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pyswarm/pso.py", line 74, in
obj = lambda x: func(x, *args, **kwargs)
File "main.py", line 30, in obj_fun
backtest.run_strategy(cash=1000,
File "/home/wmudit/stk/tc2k/ta/lib/c/pso_stuff/TrendBreakerPL_PSO_backtrader/BacktestTrendBreakerPL.py", line 59, in run_strategy
print(pf.show_worst_drawdown_periods(df_returns['return'], top=5))
File "/home/wmudit/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pyfolio/plotting.py", line 1664, in show_worst_drawdown_periods
drawdown_df = timeseries.gen_drawdown_table(returns, top=top)
File "/home/wmudit/.pyenv/versions/3.8.0/lib/python3.8/site-packages/pyfolio/timeseries.py", line 1008, in gen_drawdown_table
df_drawdowns.loc[i, 'Valley date'] = (valley.to_pydatetime()
AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime'

@lamres
Copy link
Owner

lamres commented Jan 31, 2023

Hey.
It's common issue in a library. This answer can help you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants