happydasch / btplotting

btplotting provides plotting for backtests, optimization results and live data from backtrader.
GNU General Public License v3.0
338 stars 84 forks source link

Solution for someone if encounters "TypeError: <class '__main__.XxxClass'> is a built-in class" in Jupyter #30

Closed GF-Huang closed 2 years ago

GF-Huang commented 2 years ago

In Jupyter you may try to plot to single browser tab with iplot=False:

plot = btplotting.BacktraderPlotting()
cerebro.plot(plot, iplot=False)

You may encounters TypeError: <class '__main__.YourStrategyClass'> is a built-in class error.

Then try this:

plot = btplotting.BacktraderPlotting()
plot.tabs.remove(btplotting.tabs.SourceTab)
cerebro.plot(plot, iplot=False)
happydasch commented 2 years ago

I have added a catch exceptions for source code viewing, will add the details for running in jupyter in readme