AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime'
Opened this issue · 1 comments
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'