kernc / backtesting.py

:mag_right: :chart_with_upwards_trend: :snake: :moneybag: Backtest trading strategies in Python.
https://kernc.github.io/backtesting.py/
GNU Affero General Public License v3.0
5.18k stars 1.02k forks source link

Bokeh error when running samples #34

Closed thomasd3 closed 4 years ago

thomasd3 commented 4 years ago

I downloaded the sample: Quick Start User Guide.jpynb

When I run it, and try to plot a graph, I get this:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-5ae8d19b00ab> in <module>
----> 1 bt.plot()

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/backtesting/backtesting.py in plot(self, results, filename, plot_width, plot_equity, plot_pl, plot_volume, plot_drawdown, smooth_equity, relative_equity, omit_missing, superimpose, show_legend, open_browser)
   1022             superimpose=superimpose,
   1023             show_legend=show_legend,
-> 1024             open_browser=open_browser)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/backtesting/_plotting.py in plot(results, df, indicators, filename, plot_width, plot_equity, plot_pl, plot_volume, plot_drawdown, smooth_equity, relative_equity, omit_missing, superimpose, show_legend, open_browser)
    561         toolbar_options=dict(logo=None),
    562         merge_tools=True,
--> 563         **kwargs
    564     )
    565     show(fig, browser=None if open_browser else 'none')

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/bokeh/layouts.py in gridplot(children, sizing_mode, toolbar_location, ncols, plot_width, plot_height, toolbar_options, merge_tools)
    293 
    294     # Integrity checks & set-up
--> 295     _verify_sizing_mode(sizing_mode)
    296 
    297     if toolbar_location:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/bokeh/layouts.py in _verify_sizing_mode(sizing_mode)
    449 def _verify_sizing_mode(sizing_mode):
    450     if sizing_mode not in SizingMode:
--> 451         raise ValueError("Invalid value of sizing_mode: %s" % sizing_mode)
    452 
    453 

ValueError: Invalid value of sizing_mode: stretch_width

what could be the reason? the same sample works well within https://notebooks.gesis.org/binder/jupyter/user/kernc-backtesting.py-5o73q35k/lab

kernc commented 4 years ago

Have you tried upgrading Bokeh?

pip install -U bokeh

The master branch works for me with the latest Bokeh version.

thomasd3 commented 4 years ago

yes, that was the issue: I'm testing backtesting.py vs. backtrader and backtrader requires an older version of Bokeh