Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    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

    Indicators/Strategies/Analyzers
    1
    2
    411
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Yacc Don
      Yacc Don last edited by

      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 1 Reply Last reply Reply Quote 0
      • Yacc Don
        Yacc Don @Yacc Don last edited by

        @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
        
        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors