-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
-
Hi all,
Anybody experiencing a problem with Bokeh not plotting in Jupyter? I'm running the minimal example with Python 3.7.3, Jupyter Notebook 6.1.5, and Bokeh 2.3.0. I looked at some closed issues but the only solution was setting this line
backtesting.set_bokeh_output(notebook=False)
I tried true and false and neither worked. Anybody else having the same issue?
`
# In[1]:
import backtesting
import backtesting.lib
import backtesting.test
backtesting.set_bokeh_output(notebook=False)
# In[2]:
class SmaCross(backtesting.Strategy):
n1 = 10
n2 = 20
def init(self):
close = self.data.Close
self.sma1 = self.I(backtesting.test.SMA, close, self.n1)
self.sma2 = self.I(backtesting.test.SMA, close, self.n2)
def next(self):
if backtesting.lib.crossover(self.sma1, self.sma2):
self.buy()
elif backtesting.lib.crossover(self.sma2, self.sma1):
self.sell()
# In[3]:
bt = backtesting.Backtest(backtesting.test.GOOG, SmaCross,
cash=10000, commission=.002,
exclusive_orders=True)
bt.run()
# In[4]:
bt.plot()
`
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment 1 reply
-
I will say I am running the notebook on a Raspberry Pi and hosting the notebook publicly so that I can access it from my computer. Believe this is the issue. It's noted that I can set backtesting.set_bokeh_output(notebook=False)
to False and can then open the html file separately. For now this is a fine workaround. Sorry if I'm taking up space on the forums here!
Beta Was this translation helpful? Give feedback.
All reactions
-
😄 1
-
backtesting.set_bokeh_output(notebook=True)
should be a working default for Jupyter notebooks.
The Bokeh resources are loaded from their remote CDN. Do you run an ad-blocker perhaps?
You should see an image like this upon any first backtesting
import:
Screenshot_2021年03月14日_04-41-43
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1