You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I calculated support & resistance and then created a function ("SIGNAL") that returns a list of signals, when I created the indicator "self.signal" on the "init" function, I passed the "SIGNAL" function. But when I tried to get the stats of the backtest, i get the next exception: "ValueError: attempt to get argmax of an empty sequence".
Actual Behavior
---------------------------------------------------------------------------
ValueErrorTraceback(mostrecentcalllast)/tmp/ipykernel_6680/2172180610.pyin <module>
5# --------------------------------Stats--------------------------------6bt=Backtest(df1,S_R_RSI,cash=1000000,margin=1/1,commission=0.0006,trade_on_close=True,hedging=True)
---->7stat=bt.run()8print(stat)9# print(f'Ret/DD Ratio: {retDD_ratio(stat)}')
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/backtesting/backtesting.pyinrun(self, **kwargs)1137strategy: Strategy=self._strategy(broker,data,kwargs)1138
-> 1139strategy.init()1140data._update()# Strategy.init might have changed/added to data.df1141
/tmp/ipykernel_6680/1588484572.pyininit(self)25close=self.data.Close26
--->27self.signal=self.I(lambda: SIGNAL)28self.rsi=self.I(lambda: ta.rsi(self.data.Close.s,length=self.rsi_window))29
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/backtesting/backtesting.pyinI(self,func,name,plot,overlay,color,scatter, *args, **kwargs)137138# Optionally flip the array if the user returned e.g. `df.values`
--> 139ifis_arraylikeandnp.argmax(value.shape) == 0:
140value=value.T141
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/numpy/core/overrides.pyinargmax(*args, **kwargs)
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/numpy/core/fromnumeric.pyinargmax(a,axis,out,keepdims)1214"""
1215kwds={'keepdims': keepdims}ifkeepdimsis not np._NoValueelse{}->1216return_wrapfunc(a,'argmax',axis=axis,out=out, **kwds)12171218
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/numpy/core/fromnumeric.pyin_wrapfunc(obj,method, *args, **kwds)52bound=getattr(obj,method,None)53ifboundisNone:
--->54return_wrapit(obj,method, *args, **kwds)5556try:
~/miniconda3/envs/TRADING/lib/python3.9/site-packages/numpy/core/fromnumeric.pyin_wrapit(obj,method, *args, **kwds)41exceptAttributeError:
42wrap=None
--->43result=getattr(asarray(obj),method)(*args, **kwds)44ifwrap:
45if not isinstance(result,mu.ndarray):
ValueError: attempttogetargmaxofanemptysequence
Expected Behavior
I calculated support & resistance and then created a function ("SIGNAL") that returns a list of signals, when I created the indicator "self.signal" on the "init" function, I passed the "SIGNAL" function. But when I tried to get the stats of the backtest, i get the next exception: "ValueError: attempt to get argmax of an empty sequence".
Actual Behavior
Steps to Reproduce
Additional info
The text was updated successfully, but these errors were encountered: