Skip to content

Example code not working when plot  #1051

Closed
@iampkn

Description

@iampkn

Expected Behavior

charts plotted

Actual Behavior

Follow traceback

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
[d:\machine_learning_examples\tf2.0\backtest.ipynb](file:///D:/machine_learning_examples/tf2.0/backtest.ipynb) Cell 1 in 3
     [28](vscode-notebook-cell:/d%3A/machine_learning_examples/tf2.0/backtest.ipynb#W0sZmlsZQ%3D%3D?line=27) output = bt.run()
     [29](vscode-notebook-cell:/d%3A/machine_learning_examples/tf2.0/backtest.ipynb#W0sZmlsZQ%3D%3D?line=28) print(output)
---> [30](vscode-notebook-cell:/d%3A/machine_learning_examples/tf2.0/backtest.ipynb#W0sZmlsZQ%3D%3D?line=29) bt.plot()

File [c:\Users\nguye\anaconda3\envs\env_dlearning\lib\site-packages\backtesting\backtesting.py:1592](file:///C:/Users/nguye/anaconda3/envs/env_dlearning/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,
...
    348     sizing_mode=sizing_mode,
    349 )
    351 return gp

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

Steps to Reproduce

The code I using is the code at your homepage

from backtesting import Backtest, Strategy
from backtesting.lib import crossover

from backtesting.test import SMA, GOOG


class SmaCross(Strategy):
    n1 = 10
    n2 = 20

    def init(self):
        close = self.data.Close
        self.sma1 = self.I(SMA, close, self.n1)
        self.sma2 = self.I(SMA, close, self.n2)

    def next(self):
        if crossover(self.sma1, self.sma2):
            self.buy()
        elif crossover(self.sma2, self.sma1):
            self.sell()


bt = Backtest(GOOG, SmaCross,
              cash=10000, commission=.002,
              exclusive_orders=True)

output = bt.run()
bt.plot()

Additional info

  • Backtesting version: 0.3.3
  • bokeh: 3.2.2
  • OS: Windown 64

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamIssue affects a dependency of ours

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions