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

Daily historic data with IB runs into error when more than 250 records retreived

  • I'm using the IB broker to request daily prices on QQQ going back a couple of years using the following call:

        data = store.getdata(dataname='QQQ', timeframe=bt.TimeFrame.Days, compression=1, rtbar=False, fromdate=datetime.datetime.strptime('03/10/2015', "%d/%m/%Y"), sessionend=datetime.time(16, 0))    
        cerebro.resampledata(data, timeframe=bt.TimeFrame.Days, compression=1)

    This gets the first 250 values just fine but breaks down afterwards. In my understanding the data request gets split up into multiple reqHistoricalData() calls and the sessionend parameter that I supplied gets dropped on the second request and ends up being None, thus generating an error:

    09-May-18 13:40:11 ERROR     Exception in message dispatch.  Handler 'historicalData' for 'historicalData'
    Traceback (most recent call last):
      File "/usr/local/lib/python2.7/site-packages/ib/opt/", line 44, in __call__
      File "/usr/local/lib/python2.7/site-packages/backtrader/stores/", line 937, in historicalData
        dteos = datetime.combine(dt, sessionend)
    TypeError: combine() argument 2 must be datetime.time, not None

  • Is there a way to submit a formal bug report on this? I didn't see Issues on github. I'd love to use this framework, but this is a real blocker at this point.

  • administrators

    You may give the development branch a try. There is correction for this.

  • Thanks for the patch. This looks like it is working.