Skip to content

Plotting does not work and raises an error with Bokeh #1069

@Umutoni-ga

Description

@Umutoni-ga

Expected Behavior

Using a backtest instance to plot (calling the plot() function) the graphs of the performance of the strategy.

Actual Behavior

I installed the Backtesting framework and ran a simple strategy but when I call plot() on a backtest instance I get a TypeError because of Bokeh


TypeError Traceback (most recent call last)
d:\CMU-A\Notebooks\FQAAT\Assignment 3\Bollinger Bands.ipynb Cell 35 line 1
----> 1 backtest.plot()

File c:\Users\Gaella\anaconda3\envs\general\Lib\site-packages\backtesting\backtesting.py:1592, in Backtest.plot(self, results, filename, plot_width, plot_equity, plot_return, plot_pl, plot_volume, plot_drawdown, smooth_equity, relative_equity, superimpose, resample, reverse_indicators, show_legend, open_browser)
1589 raise RuntimeError('First issue backtest.run() to obtain results.')
1590 results = self._results
-> 1592 return plot(
1593 results=results,
1594 df=self._data,
1595 indicators=results._strategy._indicators,
1596 filename=filename,
1597 plot_width=plot_width,
1598 plot_equity=plot_equity,
1599 plot_return=plot_return,
1600 plot_pl=plot_pl,
1601 plot_volume=plot_volume,
1602 plot_drawdown=plot_drawdown,
1603 smooth_equity=smooth_equity,
1604 relative_equity=relative_equity,
1605 superimpose=superimpose,
1606 resample=resample,
1607 reverse_indicators=reverse_indicators,
1608 show_legend=show_legend,
...
348 sizing_mode=sizing_mode,
349 )
351 return gp

TypeError: bokeh.models.tools.Toolbar() got multiple values for keyword argument 'logo'

Steps to Reproduce

  1. create a simple strategy class
  2. create a backtest object
  3. backtest the strategy using run()
  4. plot the strategy using plot()
class BBtrategy(Strategy):

    def init(self):
      #some indicator logic
       pass

    def next(self):
      #some trading rules
        pass


backtest = Backtest(eur_usd, BollingerBandsStrategy)
backtest.run()
backtest.plot()

Additional info

  • Backtesting version: 0.3.3
  • bokeh.__version__: 3.2.2
  • OS: Windows-10-10.0.22621-SP0

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions