For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

cerebro resampledata gives incorrect close

  • 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.resampledata(data0, timeframe=bt.TimeFrame.Minutes,compression=240)
    cerebro.addsizer(bt.sizers.FixedSize, stake=0.5)
    cerebro.addstrategy(TestStrategy_CK1, var1 = var1_val)

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

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

Log in to reply