Unable to run backtesting.py on Jupyter Notebook

157 Views Asked by At
Backtest.run()

Output: <bound method Backtest.run of <backtesting.backtesting.Backtest object at 0x0000022BAA3F79A0>>

Backtest.plot()

Output:

<bound method Backtest.plot of <backtesting.backtesting.Backtest object at 0x00000234CABC06A0>>

Python version 3.9.13 [MSC v.1916 64 bit (AMD64)]

I tried copying to Spyder and Pycharm. However output is the same with additional warning of:

UserWarning: Jupyter Notebook detected. Setting Bokeh output to notebook. This may not work in Jupyter clients without JavaScript support (e.g. PyCharm, Spyder IDE). Reset with `backtesting.set_bokeh_output(notebook=False)`.
  warnings.warn('Jupyter Notebook detected. '

Where attempted to resolve with:

backtesting.set_bokeh_output(notebook=False)

However, output is still:

[*********************100%%**********************]  1 of 1 completed
<bound method Backtest.run of <backtesting.backtesting.Backtest object at 0x00000208775CBF70>>
1

There are 1 best solutions below

0
On

please read the UserWarning you posted:

UserWarning: Jupyter Notebook detected. Setting Bokeh output to notebook. This may not work in Jupyter clients without JavaScript support (e.g. PyCharm, Spyder IDE)

Your code wants to run in a Jupyter Notebook. If you use PyCharm, a very basic version of jupyter notebook should be installed, too.

Run the command jupyter notebook in the Terminal of PyCharm. This should open a local server in a new broswer tab. Open a new Notebook and run your code. Most likly this should work and give you the wanted figure.

If you need more information how to start with notebooks, read this guide.