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/

    IB Backtesting stuck at status Delayed

    General Code/Help
    2
    4
    581
    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.
    • Ahmed Sobhy
      Ahmed Sobhy last edited by

      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()
      
      
      B 2 Replies Last reply Reply Quote 0
      • B
        backtrader administrators @Ahmed Sobhy last edited by

        @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?

        1 Reply Last reply Reply Quote 0
        • Ahmed Sobhy
          Ahmed Sobhy last edited by

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

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators @Ahmed Sobhy last edited by

            @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

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors