Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Help with referencing multiple data feeds

    General Code/Help
    3
    4
    91
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dracount
      dracount last edited by

      Hi,

      I have been looking everywhere but I don't understand how to reference the data feeds i am looking for.

      e.g. I have 2 data feeds:

      cerebro.adddata(data)
      cerebro.resampledata(data,
                           timeframe=bt.TimeFrame.Minutes,
                           compression=60
                           )
      

      the first data in adddata is minute data and the resampled is hourly.

      I want to now be able to refer to the data in my strategy as

      self.minute.close[0]
      self.hourly.close[0]
      

      is this possible?

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        Are you possibly looking for something like replay?

        1 Reply Last reply Reply Quote 0
        • A
          ab_trader last edited by

          you can refer to your data feeds inside the strategy as

          self.datas[0].close[0] # minute data feed
          self.datas[1].close[0] # hour data feed
          

          or

          self.data0.close[0] # minute data feed
          self.data1.close[0] # hour data feed
          
          1 Reply Last reply Reply Quote 0
          • dracount
            dracount last edited by

            I managed to do this and it seems to work:

                    self.minutes = self.data0
                    self.hours = self.data1
            
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
            $(document).ready(function () { app.coldLoad(); }); }