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/

    Problem with compression on data

    General Code/Help
    2
    3
    240
    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 am loading minute data from a CSV file
      e.g.

      20200525 000000;0.653390;0.653440;0.653380;0.653380;0
      20200525 000100;0.653390;0.653390;0.653370;0.653380;0
      20200525 000200;0.653370;0.653380;0.653370;0.653370;0
      20200525 000300;0.653370;0.653380;0.653370;0.653370;0
      

      my load data looks like:

      data = bt.feeds.GenericCSVData(dataname='./datas/test.csv',
                                          timeframe=bt.TimeFrame.Minutes,
                                          compression=60,
                                          dtformat=('%Y%m%d %H%M%S'),
                                          separator=';',
                                          datetime=0,
                                          open=1,
                                          high=2,
                                          low=3,
                                          close=4,
                                          volume=-1,
                                          openinterest=-1
                                          )
      
      

      but it is not running in hours

      e.g. output i get when showing date time in the strategy is:

      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T05:44:00
      2020-05-27T09:26:00
      2020-05-27T09:26:00
      2020-05-27T09:26:00
      

      I don't understand what its doing?

      Thanks

      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        @dracount said in Problem with compression on data:

        compression=60

        It seems your data is timeframe=bt.TimeFrame.Minutes and compression=1 and not 60.

        If you'd like to get the 60 minutes bars you need to resample. See here: https://www.backtrader.com/docu/data-resampling/data-resampling/

        dracount 1 Reply Last reply Reply Quote 0
        • dracount
          dracount @vladisld last edited by

          @vladisld Thank you!

          So is compression only used when resampling data? not when reading first from the csv?

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