For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
2019-10-02: The community is currently in read-only mode

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



  • 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
    


  • @backtrader

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


Log in to reply
 

});