For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

cerebro.plot() error



  • I've got below errors when trying to do cerebro.plot().
    My data files is normal csv with date/high/low/open/close.
    cerebro.plot()
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\backtrader\cerebro.py", line 991, in plot
    start=start, end=end, use=use)
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\backtrader\plot\plot.py", line 262, in plot
    self.mpyplot.setp(ax.get_xticklabels(), visible=False)
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\axes_base.py", line 63, in wrapper
    return get_method(self)(*args, **kwargs)
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\axis.py", line 1255, in get_ticklabels
    return self.get_majorticklabels()
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\axis.py", line 1207, in get_majorticklabels
    ticks = self.get_major_ticks()
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\axis.py", line 1378, in get_major_ticks
    numticks = len(self.get_majorticklocs())
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\axis.py", line 1283, in get_majorticklocs
    return self.major.locator()
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\dates.py", line 1320, in call
    return locator()
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\dates.py", line 1731, in call
    return self.tick_values(dmin, dmax)
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\dates.py", line 1741, in tick_values
    ticks = self._wrapped_locator.tick_values(nmin, nmax)
    File "C:\ProgramData\Anaconda3\envs\Yiqin\lib\site-packages\matplotlib\ticker.py", line 2009, in tick_values
    locs = vmin - step + np.arange(n + 3) * step
    MemoryError: Unable to allocate 70.8 GiB for an array with shape (9504000003,) and data type float64



  • Not enough memory for the operations you want to make. I doubt that this is related to bt, you may want to google this error and check out what are the recommendations.



  • I encountered the exact same error. Any solutions here?



  • Okay so I solved this. This is due to the new version of matplotlib, which is 3.3.0 currently. I pip installed an older version which is 3.2.2, and the graph was printed out successfully.



  • @TXY Thank you, I had this same problem and your method worked.



  • anybody was able to solve it without installing older version of mathplotlib? maybe it should be an issue on backtrader.

    i have the newest version, and it crashes with the same error ("MemoryError: Unable to allocate 70.8 GiB") only when there was no buy/sell, for example if i don't add any strategy or the strategy did not create a buy/sell order.



  • @RandomTrader88 Exactly this happened with me. I tried to run a strategy with no buy/sell signal and got this error.


Log in to reply
 

});