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



  • 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



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



  • @vladisld Thank you!

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


Log in to reply
 

});