Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Brandon La Porte
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Groups 0

    Brandon La Porte

    @Brandon La Porte

    0
    Reputation
    3
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Brandon La Porte Unfollow Follow

    Latest posts made by Brandon La Porte

    • RE: Multi-Data example help

      @Brandon-La-Porte It was indeed something easy, wrong indentation level.

      for i, data in enumerate(datas):
                  if i != 0:
                      data.plotinfo.plotmaster = datas[0]
      
                  cerebro.adddata(data)
      

      This was the wrong indentation and ended up being ran more the once.

      posted in General Code/Help
      Brandon La Porte
      Brandon La Porte
    • Multi-Data example help

      Hi,
      I'm trying to get multiple feeds to show up on the same plot. I am using theMulti-Data Example as a reference. Here is my code below

      
      # imports above here 
      
      if __name__ == "__main__":
      
          # adjust plot settings
          style.use("bmh")
          plt.rcParams["figure.figsize"] = [10.0, 8.0]
          plt.rcParams["figure.dpi"] = 150
      
          # cerebro is the backtest runner
          cerebro = bt.Cerebro()
      
          # ------------------------------------------ #
          # --- Get, process and add data to feeds --- #
          # ------------------------------------------ #
      
          data_dir = "data/vanguardBnH/"
          files = os.listdir(data_dir)
          datas = []
      
          for filename in files:
              datapath = os.path.join(data_dir, filename)
              # Create a Data Feed
      
              datas.append(
                  bt.feeds.YahooFinanceCSVData(
                      dataname=datapath,
                      # Do not pass values before this date
                      fromdate=datetime.datetime(2017, 1, 1),
                      # Do not pass values after this date
                      todate=datetime.datetime(2019, 12, 31),
                      reverse=False,
                  )
              )
      
              for i, data in enumerate(datas):
                  if i != 0:
                      data.plotinfo.plotmaster = datas[0]
      
                  cerebro.adddata(data)
      
      
          # ------------------------------------------ #
          # --- Cerebro Backtest setup             --- #
          # ------------------------------------------ #
      
          strats = cerebro.run()
      
          cerebro.plot(volume=False)
      
      

      This results in the following plot
      Figure_0.png

      I assume I am missing something really easy but I haven't been able to figure it out.

      posted in General Code/Help
      Brandon La Porte
      Brandon La Porte