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/

    cerebro resampledata gives incorrect close

    General Code/Help
    2
    3
    63
    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.
    • J
      jeanpaul last edited by

      hi all,

      I m testing the platform, and checking if I can get same results as I have with other libraries and TV. Results so far were not the same (although not far off), and I managed to pin it down to one issue: I load a datafeed of 5m timeframe, and then I resample it to 4h. What I see now is that the 4h close is off by 5 minutes. More concretely in an example:the 4h-tick which started at 04:00 will get its close price at 08:00. on a 5m scale, this means that the same close price comes from the 5m which started at 07:55. When I use cerebro.resampledata however, the close of my 4h at 08:00 gets calculated from the 5m close which STARTED at 08:00,hence the close is from 08:05, which is off by 5 minutes.

      cerebro.adddata(data0)
      cerebro.resampledata(data0, timeframe=bt.TimeFrame.Minutes,compression=240)
      
      cerebro.broker.setcash(20000.0)
      cerebro.addsizer(bt.sizers.FixedSize, stake=0.5)
      cerebro.broker.setcommission(commission=0.001)
      cerebro.addstrategy(TestStrategy_CK1, var1 = var1_val)
      cerebro.run()
      

      Could you please tell me if this is a known issue, and I m wrong somewhere? or if it might be a bug?
      cheers

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

        https://community.backtrader.com/topic/1629/problem-with-resampling-1m-data-to-5m-15m/3

        1 Reply Last reply Reply Quote 1
        • J
          jeanpaul last edited by

          thanks, that helped to understand the issue.
          finally, in my specific case, the boundoff parameter now puts everything as I want it.

          cerebro.resampledata(data0, timeframe=bt.TimeFrame.Minutes,compression=240,boundoff=5)
          
          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(); }); }