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

IB Backtesting stuck at status Delayed



  • I get status Delayed and keep stuck, even thought the same code was working a day ago. What could be the cause of this?

    console output:
    Server Version: 76
    TWS Time at connection:20180901 14:19:00 EET
    ***** DATA NOTIF: DELAYED

    from __future__ import (absolute_import, division, print_function,
                            unicode_literals)
    import backtrader as bt
    import datetime
    
    class St(bt.Strategy):
        def logdata(self):
            txt = []
            txt.append('{}'.format(len(self)))
    
            txt.append('{}'.format(
                self.data.datetime.datetime(0).isoformat())
            )
            txt.append('{:.5f}'.format(self.data.open[0]))
            txt.append('{:.5f}'.format(self.data.high[0]))
            txt.append('{:.5f}'.format(self.data.low[0]))
            txt.append('{:.5f}'.format(self.data.close[0]))
            txt.append('{:.5f}'.format(self.data.volume[0]))
            print(','.join(txt))
    
        def next(self):
            print("here")
            self.logdata()
    
        data_live = False
    
        def notify_data(self, data, status, *args, **kwargs):
            print('*' * 5, 'DATA NOTIF:', data._getstatusname(status),
                  *args)
            if status == data.LIVE:
                self.data_live = True
    
    
    def run(args=None):
        cerebro = bt.Cerebro(stdstats=False)
        store = bt.stores.IBStore(host='127.0.0.1', port=7497)
        data = store.getdata(dataname='EUR.USD-CASH-IDEALPRO',
                             timeframe=bt.TimeFrame.Ticks, fromdate= datetime.datetime(2017, 1, 1), todate=datetime.datetime(2018, 1, 1))
        cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes,
                             compression=1)
        cerebro.addstrategy(St)
        cerebro.run()
    
    
    if __name__ == '__main__':
        run()
    
    

  • administrators

    @ahmed-sobhy said in IB Backtesting stuck at status Delayed:

    TWS Time at connection:20180901 14:19:00 EET
    

    It's Saturday, isn't it?



  • I am requesting history data not real time, shouldn't it work even if the market is closed?


  • administrators

    @ahmed-sobhy said in IB Backtesting stuck at status Delayed:

        data = store.getdata(dataname='EUR.USD-CASH-IDEALPRO',
                             timeframe=bt.TimeFrame.Ticks, fromdate= datetime.datetime(2017, 1, 1), todate=datetime.datetime(2018, 1, 1))
        cerebro.resampledata(data, timeframe=bt.TimeFrame.Minutes,
                             compression=1)
    

    Where is the historical parameter? - See Docs - DataFeeds Reference - IBData