Backtrader Community

    • 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/

    Is there a bug of rightedge=False with resampling()

    General Code/Help
    1
    2
    340
    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.
    • G
      G_will last edited by

      extract and modify some codes from samples/bidask-to-ohlc/bidask-to-ohlc.py:

      resample ticks data to 1 minute bar data:

          data = btfeeds.GenericCSVData(
              dataname='../../datas/bidask2.csv',
              dtformat='%d/%m/%y',
              # tmformat='%H%M%S',  # already the default value
              # datetime=0,  # position at default
              time=1,  # position of time
              open=5,  # position of open
              high=5,
              low=5,
              close=5,
              volume=7,
              openinterest=-1,
              timeframe=bt.TimeFrame.Ticks)
      
          cerebro.resampledata(data,
                               timeframe=bt.TimeFrame.Minutes,
                               compression=1)
      

      output:

      2016-03-01 23:44:00,130.52,130.52,130.52,130.52,3000000.0
      2016-03-01 23:50:00,130.51,130.55,130.55,130.55,3650000.0
      2016-03-01 23:52:00,130.5,130.5,130.5,130.5,1200000.0
      2016-03-01 23:53:00,130.495,130.495,130.495,130.495,1100000.0
      2016-03-01 23:54:00,130.48,130.48,130.48,130.48,600000.0
      2016-03-01 23:55:00,130.47,130.47,130.47,130.47,900000.0
      

      It is right.

      But, If I want to label data use starting boundary and set rightedge=False

          data = btfeeds.GenericCSVData(
              dataname='../../datas/bidask2.csv',
              dtformat='%d/%m/%y',
              # tmformat='%H%M%S',  # already the default value
              # datetime=0,  # position at default
              time=1,  # position of time
              open=5,  # position of open
              high=5,
              low=5,
              close=5,
              volume=7,
              openinterest=-1,
              timeframe=bt.TimeFrame.Ticks)
      
          cerebro.resampledata(data,
                               timeframe=bt.TimeFrame.Minutes,
                               compression=1,
                               rightedge=False)
      

      and output:

      2016-03-01 23:43:27,130.52,130.52,130.52,130.52,3000000.0
      2016-03-01 23:49:27,130.51,130.55,130.55,130.55,3650000.0
      2016-03-01 23:51:25,130.5,130.5,130.5,130.5,1200000.0
      2016-03-01 23:52:27,130.495,130.495,130.495,130.495,1100000.0
      2016-03-01 23:53:25,130.48,130.48,130.48,130.48,600000.0
      2016-03-01 23:54:00,130.47,130.47,130.47,130.47,900000.0
      

      It seems wrong, some date lebal was not at the starting boundary. I think it should be :

      2016-03-01 23:43:00,130.52,130.52,130.52,130.52,3000000.0
      2016-03-01 23:49:00,130.51,130.55,130.55,130.55,3650000.0
      2016-03-01 23:51:00,130.5,130.5,130.5,130.5,1200000.0
      2016-03-01 23:52:00,130.495,130.495,130.495,130.495,1100000.0
      2016-03-01 23:53:00,130.48,130.48,130.48,130.48,600000.0
      2016-03-01 23:54:00,130.47,130.47,130.47,130.47,900000.0
      
      1 Reply Last reply Reply Quote 0
      • G
        G_will last edited by

        @backtrader

        Is it a bug? or my using method is not correct?

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