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/

    Idiomatic way for adding multiple ibstore live data with different resampling and the same backfill start date

    General Code/Help
    2
    3
    488
    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.
    • Z
      z_kvn last edited by

      Hello

      Suppose I want live data for a same security in 4 different timeframes: 1 minute, 15 minutes, 1 hour and 1 day, and trade on the smallest granular data which is 1 minute bar. I also need to backfill from a specific historical start date to make sure good indicator values coming out from the daily bars. To make sure I don't miss any good minute bar data, the smallest granular data source is 20 seconds bar with "qcheck=2" and "rtbar=True". Is below idiomatic way to do it? Do I have to specify "fromdate" argument for every "ibstore.getdata(...)" line?

      Many thanks.

      Kevin

      data0= ibstore.getdata('FOO', timeframe=bt.TimeFrame.Seconds, compression=20, 
                          rtbar=True,
                          qcheck =2,
                          fromdate=datetime.datetime(2018,9,1) )
      
      min_bar= cerebro.resampledata(data0, timeframe=bt.TimeFrame.Minutes,compression=1,name='min_bar')
      
      data1= ibstore.getdata('FOO', timeframe=bt.TimeFrame.Minutes,  compression=15,
                          fromdate=datetime.datetime(2018,9,1))    
      
      quarter_bar= cerebro.resampledata(data1, timeframe=bt.TimeFrame.Minutes,
                          compression=15,name='quarter_bar')    
      
      data2= ibstore.getdata('FOO', timeframe=bt.TimeFrame.Minutes,  compression=60, 
                          fromdate=datetime.datetime(2018,9,1))    
      
      hr_bar= cerebro.resampledata(data2, timeframe=bt.TimeFrame.Minutes,
                          compression=60,name='hr_bar')    
      
      data3=ibstore.getdata(data2,timeframe=bt.TimeFrame.Days,compression=1,
                          fromdate=datetime.datetime(2018,9,1))   
      
      day_bar= cerebro.resampledata(data3, timeframe=bt.TimeFrame.Days,
                          compression=1,name='day_bar')
      Z 1 Reply Last reply Reply Quote 0
      • Z
        z_kvn @z_kvn last edited by

        The code is not quite stable as sometimes it would return an error like below, sometimes it would run just fine.

        ***** DATA NOTIF: DELAYED
        ***** DATA NOTIF: DELAYED
        ***** DATA NOTIF: DELAYED
        ***** DATA NOTIF: DELAYED
        ***** DATA NOTIF: UNKNOWN -420
        Traceback (most recent call last):
        .......
        return self.data.datetime.datetime(0)
        File ".../backtrader/linebuffer.py", line 387, in datetime
        return num2date(self.array[self.idx + ago],
        IndexError: array index out of range

        1 Reply Last reply Reply Quote 0
        • Y
          yoghurtshawn last edited by

          I found a similar exception as well. Does anyone have some idea about this problem?

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