Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. JuanM
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Groups 0

    JuanM

    @JuanM

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    JuanM Unfollow Follow

    Latest posts made by JuanM

    • ERROR Pyfolio and Resample

      Hi, I've been working with backtrader for about a year, I find this library incredible, it's the first time I've interacted with the forum and I didn't want to miss the opportunity to recognize the incredible work of the development team and its community.

      I am working with 1h candles.

      datas = btfeeds.PandasData(dataname =datas,
      timeframe=bts.TimeFrame.Minutes,compression=60)
      

      I then do a data shift to a 1 day per candle frame.

      cerebro.resampledata(datas,timeframe=bts.TimeFrame.Days,
      compression=1)
      

      but at this moment, when adding pyfolio, it throws me an error,
      the error disappears when removing pyfolio or deleting resampe data.
      With the rest of analyzers it doesn't happen, they work fine.

      the error found is this

      py", line 52, in RunBacktraderResample
      thestrats = cerebro.run()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\cerebro.py", line 1127, in run
      runstrat = self.runstrategies(iterstrat)
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\cerebro.py", line 1298, in runstrategies
      self._runnext(runstrats)
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\cerebro.py", line 1630, in _runnext
      strat._next()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\strategy.py", line 350, in _next
      self._next_analyzers(minperstatus)
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\strategy.py", line 388, in _next_analyzers
      analyzer._prenext()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\analyzer.py", line 150, in _prenext
      child._prenext()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\analyzer.py", line 152, in _prenext
      self.prenext()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\analyzer.py", line 229, in prenext
      self.next()
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\analyzers\positions.py", line 78, in next
      pvals = [self.strategy.broker.get_value([d]) for d in self.datas]
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\analyzers\positions.py", line 78, in <listcomp>
      pvals = [self.strategy.broker.get_value([d]) for d in self.datas]
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\brokers\bbroker.py", line 415, in get_value
      return self._get_value(datas=datas, lever=lever)
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\brokers\bbroker.py", line 439, in _get_value
      dvalue = comminfo.getvaluesize(position.size, data.close[0])
      
      File "C:\Users\J\anaconda3\lib\site-packages\backtrader\linebuffer.py", line 163, in getitem
      return self.array[self.idx + ago]
      
      IndexError: array index out of range
      

      I really appreciate your answers, thank you very much!!

      posted in Indicators/Strategies/Analyzers
      J
      JuanM