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/

    I set bt.TimeFrame.Days, with interactive brokers, but getting ticks?

    General Code/Help
    2
    5
    423
    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.
    • rami
      rami last edited by rami

      Next called every tick, and
      inside
      self.dnames['GOLDLONGD'].close[0] is real time value, but self.dnames['GOLDLONGD'].close[-1] previus tick, not Yestarday as i expect.

          def next(self):
              print("NEXT ") 
              print("{}".format(self.data.datetime.datetime(0).isoformat()))
              print("MKT(len={}) [0]{} [-1]{}".format(len(self.dnames['MKTD']),
                       self.dnames['MKTD'].close[0],
                       self.dnames['MKTD'].close[-1]))
      
           spygd = store.getdata(dataname='SPYG-STK-ARCA-USD',timeframe=bt.TimeFrame.Days)
           tltd = store.getdata(dataname='TLT-STK-ARCA-USD',timeframe=bt.TimeFrame.Days)
          gldd = store.getdata(dataname='IAU-STK-ARCA-USD',timeframe=bt.TimeFrame.Days)
          cerebro.addcalendar("NYSE")
          cerebro.adddata(spygd, name='MKTD')
          cerebro.adddata(tltd, name='BONDLONGD')
          cerebro.adddata(gldd, name='GOLDLONGD')
          
      
      

      It's started ok, but later become very strange - i marked it BOLD

      NEXT
      2019-04-15T23:59:59.999986
      MKT(len=249) [0]38.1 [-1]38.05
      NEXT
      2019-04-16T23:59:59.999986
      MKT(len=250) [0]38.0 [-1]38.1
      NEXT
      2019-04-17T23:59:59.999986
      MKT(len=251) [0]37.85 [-1]38.0
      ***** DATA NOTIF: MKTD LIVE
      NEXT
      2019-04-17T23:59:59.999986
      MKT(len=251) [0]37.85 [-1]38.0
      .
      .
      .
      NEXT
      2019-04-17T23:59:59.999986
      MKT(len=251) [0]37.85 [-1]38.0
      ***** DATA NOTIF: BONDLONGD LIVE
      NEXT
      2019-04-17T23:59:59.999986
      MKT(len=251) [0]37.85 [-1]38.0
      NEXT
      2019-04-18T13:18:29.462995
      MKT(len=252) [0]37.89 [-1]37.85
      NEXT
      2019-04-18T13:18:29.462995
      MKT(len=252) [0]37.89 [-1]37.85
      NEXT
      2019-04-18T13:18:29.462995
      MKT(len=252) [0]37.89 [-1]37.85

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

        https://medium.com/@danjrod/interactive-brokers-in-python-with-backtrader-23dea376b2fc

        1 Reply Last reply Reply Quote 0
        • rami
          rami last edited by rami

          @backtrader thank you for reference, i took your referenced sample, and alter to make my own code.
          i replaced resampledata to cerebro.adddata i use Days instead of ticks.
          when i use resampledata - cerebro crashed, i open issue, but found by adddata it's run stable (without crashes)

          Could you please point me what i doing wrong??

          1 Reply Last reply Reply Quote 0
          • rami
            rami last edited by

            @backtrader could you please advice why resampledata not working stable with IB ?

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

              That's a huge statement. You faced a problem, which doesn't mean it doesn't work in a stable manner.

              In any case, there is not much advice I can offer, except for things like decreasing the number of symbols you request from IB simultaneously (that seems to work like a charm for everyone who doesn't know about the limitations placed by IB)

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