Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bokeh not plotting the official website snippet #926

Closed
jsulopzs opened this issue Mar 2, 2023 · 1 comment
Closed

Bokeh not plotting the official website snippet #926

jsulopzs opened this issue Mar 2, 2023 · 1 comment
Labels
duplicate This issue or pull request already exists

Comments

@jsulopzs
Copy link

jsulopzs commented Mar 2, 2023

Expected Behavior

Actual Behavior

You may watch the following Loom video to understand the possible error:

https://www.loom.com/share/a078b84b92ba46feb1a9abf2d8fc8b93

Steps to Reproduce

  1. Install backtesting library pip install backtesting
  2. Copy-paste a snippet of code from the official website.
  3. Execute the code.
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.__version__: 3.0.3
  • OS: GitHub codespaces
@jsulopzs
Copy link
Author

jsulopzs commented Mar 2, 2023

Already solved in #803

@jsulopzs jsulopzs closed this as completed Mar 2, 2023
@kernc kernc added the duplicate This issue or pull request already exists label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants