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/

    Upgrading from 1.9.27.105 -> 1.9.43.116 breaks things

    General Discussion
    3
    5
    1347
    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.
    • X
      xnox last edited by

      Hello,

      I'm trying to upgrade from backtrader 1.9.27.105 to a more recent release, and things break for me.

      First of all, I operate mostly on minute data and previously all of my charts would work on minute bars.

      Now, the data appears to be loading in a daily timeframe, even though it is clearly minute data.... How do I fix this?

      Then when I try to plot things, I get the following traceback:

          cerebro.plot()
        File "/home/xnox/ig/backtrader/backtrader/cerebro.py", line 739, in plot
          start=start, end=end)
        File "/home/xnox/ig/backtrader/backtrader/plot/plot.py", line 218, in plot
          self.plotdata(data, self.dplotsover[data])
        File "/home/xnox/ig/backtrader/backtrader/plot/plot.py", line 656, in plotdata
          color=color, label=datalabel)
        File "/home/xnox/ig/backtrader/backtrader/plot/finance.py", line 594, in plot_lineonclose
          **kwargs)
        File "/home/xnox/ig/backtrader/backtrader/plot/finance.py", line 534, in __init__
          ax.add_line(self.loc)
        File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 1708, in add_line
          self._update_line_limits(line)
        File "/usr/lib/python3/dist-packages/matplotlib/axes/_base.py", line 1730, in _update_line_limits
          path = line.get_path()
        File "/usr/lib/python3/dist-packages/matplotlib/lines.py", line 925, in get_path
          self.recache()
        File "/usr/lib/python3/dist-packages/matplotlib/lines.py", line 632, in recache
          raise RuntimeError('xdata and ydata must be the same length')
      RuntimeError: xdata and ydata must be the same length
      
      

      Any idea how to work out which line / what is bombing out here?

      1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by

        Looking through latest threads on multi-frame data - it seems that you need compression param to be used for both .adddata and .resampledata.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        X 1 Reply Last reply Reply Quote 0
        • X
          xnox @ab_trader last edited by

          @ab_trader

          Hm,

          TypeError: adddata() got an unexpected keyword argument 'compression'

          Adding compression to the BacktraderCSVData object, and resampledata call, still results in the inability to plot.

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            @xnox said in Upgrading from 1.9.27.105 -> 1.9.43.116 breaks things:

            TypeError: adddata() got an unexpected keyword argument 'compression'

            @ab_trader meant to add timeframe and compressoin to data feed creation and not to adddata (a small typo)

            Releases have been tightening that, using those parameters more and more (and more with the addition of trading calendars). sessionend will now be needed more and more. In the code in your github report you can add:

            timeframe=bt.TimeFrame.Minutes,
            compression=5,
            sessionend=datetime.time(17, 30),
            

            And things will plot. But they may easily break.

            The problem here being how the axes in matplotlib align if they have different lengths and things break easily.

            1 Reply Last reply Reply Quote 0
            • B
              backtrader administrators last edited by

              There was a pull request some time ago which added a calculation for aligning unequal (lengthwise) streams when plotting with multiple figures. The calculation was not 100% accurate, but it should be now with this commit.

              https://github.com/mementum/backtrader/commit/f0dbadef2bc61ba1046e7f07b6a944aae864b96f

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors