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/

    How to fill missing data

    General Code/Help
    2
    3
    808
    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.
    • M
      MikeTheTIke last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • P
        Paska Houso last edited by

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

        1 Reply Last reply Reply Quote 0
        • M
          MikeTheTIke last edited by

          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?

          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(); }); }