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

How to fill missing data



  • I tried many ways to get SessionFiller to work...without success:

    Data looks like this (with some data missing):

    2017 11 19 02:40:00,0.026441389694809914,0.026441389694809914,0.026441389694809914,0.026441389694809914,158.64834594726562
    2017 11 19 02:45:00,,,,,
    2017 11 19 02:50:00,,,,,
    2017 11 19 02:55:00,,,,,
    2017 11 19 03:00:00,0.026379242539405823,0.026379242539405823,0.026301197707653046,0.026301197707653046,359.79620361328125
    

    Some sample code:

    dtstart = datetime.datetime.strptime('2017 11 18 12:05:00', '%Y %m %d %H:%M:%S')
    dtend = datetime.datetime.strptime('2017 12 18 12:05:00', '%Y %m %d %H:%M:%S')
    
    # Create a Data Feed
    data = bt.feeds.GenericCSVData(
        timeframe=bt.TimeFrame.Minutes,
        compression=5,
        dataname=datapath,
        openinterest=-1,
        fromdate=dtstart,
        todate=dtend,
        dtformat="%Y %m %d %H:%M:%S",
        sessionstart=dtstart,
        sessionend=dtend,
        )
    data.addfilter(bt.filters.SessionFiller, fill_vol=0.0)
    cerebro.adddata(data)
    

    I tried many variations, but in none of the plots or logic it seems SessionFiller is actually inserting something.

    What's wrong here?



  • Your data is not missing ... it's simply empty, but you still have a timestamp ... that may be the key.



  • That's one of the variations I tried :) I removed the "empty" lines and ran the code above. In the plots the missing timespans are missing as well. I would have expected them to be filled with the last values.

    Or is there a special way to access the filled data?


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.