For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
Exception inputs are all NaN if runonce=False
-
Here is my code
class UserStockStrategy(bt.Strategy): def __init__(self): self.ind = bt.talib.LINEARREG_SLOPE(bt.talib.LINEARREG_SLOPE(self.datas[0].close, timeperiod=5), timeperiod=2) #recursive formula cerebro = bt.Cerebro(runonce=False)
If runonce is True, everything is ok, and exception raised if runonce is False.
And if inner timeperiod equal to outer timeperiod, it's also fine with runonce=False.Could anybody help me? Thanks.
-
@yacc-don
if inner timeperiod is not equal to outer timeperiod, and runonce=False, the got the following excetption:File "/home/user/.local/lib/python3.7/site-packages/backtrader/lineiterator.py", line 347, in nextstart self.next() File "/home/user/.local/lib/python3.7/site-packages/backtrader/talib.py", line 217, in next out = self._tafunc(*narrays, **self.p._getkwargs()) File "/home/user/.local/lib/python3.7/site-packages/talib/__init__.py", line 27, in wrapper return func(*args, **kwargs) File "talib/_func.pxi", line 3323, in talib._ta_lib.LINEARREG_SLOPE File "talib/_func.pxi", line 68, in talib._ta_lib.check_begidx1 Exception: inputs are all NaN