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/

    Does `replaydata` support Ticks timeframe?

    General Code/Help
    2
    2
    84
    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.
    • thrall chen
      thrall chen last edited by

      I use replaydata to 5 Minutes bar with Ticks timeframe , then use bt.ind.BollingerBands get boll ind.
      but the result not as expected. The data bar not increment evey 5 minutes.
      This is my code and output:

      class Test(bt.Strategy):
          def __init__(self):
              self.bar_len = 0
              self.boll = bt.ind.BollingerBands(self.data, period=20)
      
          def next(self):
              if len(self.data) > self.bar_len:
                  logging.info("============= last ohlc and boll============")
                  logging.info(f"{bt.num2date(self.data.datetime[-1]).isoformat()} O:{self.data.open[-1]} H:{self.data.high[-1]} L:{self.data.low[-1]} C:{self.data.close[-1]}")
                  logging.info(f"Boll: UB:{self.boll.top[-1]} LB:{self.boll.bot[-1]}")
              logging.info(f"{bt.num2date(self.data.datetime[0]).isoformat()}-{self.data.open[0]}-{self.data.high[0]}-{self.data.low[0]}-{self.data.close[0]}")
              self.bar_len = len(self.data)
      

      part of output:

      2019-11-29 12:03:02,293 [INFO]- 2019-11-29T12:14:58.883124-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:02,294 [INFO]- 2019-11-29T12:14:58.969525-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:02,300 [INFO]- 2019-11-29T12:14:59.055926-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:02,301 [INFO]- 2019-11-29T12:14:59.142326-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:02,302 [INFO]- 2019-11-29T12:14:59.228727-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:02,302 [INFO]- 2019-11-29T12:14:59.315128-7548.67-7550.57-7413.07-7445.27
      2019-11-29 12:03:02,303 [INFO]- 2019-11-29T12:14:59.401528-7548.67-7550.57-7413.07-7445.38
      2019-11-29 12:03:02,310 [INFO]- 2019-11-29T12:14:59.487929-7548.67-7550.57-7413.07-7445.43
      2019-11-29 12:03:02,435 [INFO]- 2019-11-29T12:14:59.574330-7548.67-7550.57-7413.07-7445.43
      2019-11-29 12:03:02,511 [INFO]- 2019-11-29T12:14:59.660730-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:02,550 [INFO]- 2019-11-29T12:14:59.747131-7548.67-7550.57-7413.07-7445.43
      2019-11-29 12:03:02,763 [INFO]- 2019-11-29T12:14:59.833532-7548.67-7550.57-7413.07-7445.57
      2019-11-29 12:03:02,764 [INFO]- 2019-11-29T12:14:59.919932-7548.67-7550.57-7413.07-7445.57
      2019-11-29 12:03:02,765 [INFO]- 2019-11-29T12:15:00.006333-7548.67-7550.57-7413.07-7445.57
      2019-11-29 12:03:02,765 [INFO]- 2019-11-29T12:15:00.092734-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:02,856 [INFO]- 2019-11-29T12:15:00.179134-7548.67-7550.57-7413.07-7445.04
      2019-11-29 12:03:03,024 [INFO]- 2019-11-29T12:15:00.265535-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,025 [INFO]- 2019-11-29T12:15:00.351935-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,237 [INFO]- 2019-11-29T12:15:00.438336-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,238 [INFO]- 2019-11-29T12:15:00.524737-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,239 [INFO]- 2019-11-29T12:15:00.611137-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,323 [INFO]- 2019-11-29T12:15:00.697538-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,602 [INFO]- 2019-11-29T12:15:00.783939-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,603 [INFO]- 2019-11-29T12:15:00.870339-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,627 [INFO]- 2019-11-29T12:15:00.956740-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,627 [INFO]- 2019-11-29T12:15:01.043141-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,628 [INFO]- 2019-11-29T12:15:01.129541-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,629 [INFO]- 2019-11-29T12:15:01.215942-7548.67-7550.57-7413.07-7445.42
      2019-11-29 12:03:03,629 [INFO]- 2019-11-29T12:15:01.302343-7548.67-7550.57-7413.07-7445.42
      
      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        @thrall-chen said in Does `replaydata` support Ticks timeframe?:

        This is my code

        No. It is what you have chosen to post. Not the code which is running.

        • You talk about Ticks timeframe being supported ...
        • And 5 minutes

        And you choose to omit the parts of the code that actually show what you do.

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