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/

    how to inspect the data in the datafeed

    General Code/Help
    3
    5
    184
    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.
    • P
      petehe last edited by

      Hi All

      I am new to backtrader. I used to build strategy with pandas and it was easy to check the data that you are back testing and verify the strategy is working correctly.

      I am not sure what's the best way to inspect OHLC data in the data feeds, it is bit confusing for me.

      Can someone shed some light on it?

      R run-out 2 Replies Last reply Reply Quote 0
      • R
        rajanprabu @petehe last edited by

        @petehe

        I dont exactly understand your question. But backtrader had a plotting function which you can use to verify.

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

          @petehe You can use this to get logging of your ohlc.

          
          def log(self, txt, dt=None):
              """ Logging function for this strategy"""
          
              if self.p.printon:
                  dt = dt or self.datas[1].datetime.datetime(0)
                  print("%s, %s" % (dt, txt))
              else:
                  pass
          
          
          def print_signal(self):
              """Print to termianl ohlcv."""
              
              print(
                  "{} o {} \th {} \tl {} \tc {}\tv {}".format( 
                      self.datas[0].datetime.datetime(),
                      self.datas[0].open[0],
                      self.datas[0].high[0],
                      self.datas[0].low[0],
                      self.datas[0].close[0],
                      self.datas[0].volume[0],
                  )
              )
              
          def next(self):
              
              self.print_signal()
          

          RunBacktest.com

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

            @run-out I just realized looking at the code I posted that the print_signal doesn't use the log but uses its own datetime.

            RunBacktest.com

            P 1 Reply Last reply Reply Quote 1
            • P
              petehe @run-out last edited by

              @run-out thank you very much

              1 Reply Last reply Reply Quote 1
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors