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/

    Replay data not working at all with Interactive brokers

    General Code/Help
    1
    2
    78
    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.
    • Ravi Vidap
      Ravi Vidap last edited by

      Replay data looping through only Higher TimeFrame completely ignoring lower TimeFrame.

      I am ready to pay to solve this issue. I have posted this issue so many times now. Please help

      class IntraTrendStrategy(bt.Strategy):
          
          def log(self, txt, dt=None):
              ''' Logging function fot this strategy'''
              dt = dt or self.datas[0].datetime.datetime(0)
              print('%s, %s' % (dt.isoformat(), txt))
      
          def __init__(self):
              pass
      
          def start(self):
              self.counter = 0
      
          def prenext(self):
              self.counter += 1
              self.log('prenext len %d - counter %d' % (len(self), self.counter))
      
          def next(self):
              self.counter += 1
              self.log('---next len %d - counter %d' % (len(self), self.counter))
      
      
      stockkwargs = dict(
              timeframe=bt.TimeFrame.Minutes,
              compression=15,
              historical=True,  # only historical download
              fromdate=datetime.datetime(2020, 9, 1),  # get data from..
              todate=datetime.datetime(2020, 9, 13)  # get data from..
          )
      
      cerebro = bt.Cerebro(stdstats=False)
      store = bt.stores.IBStore(port=7496,clientId=5)
      data = store.getdata(dataname='TCS-STK-NSE-INR',**stockkwargs)  
      cerebro.replaydata(data,timeframe=bt.TimeFrame.Days,compression=1)
      cerebro.addstrategy(IntraTrendStrategy)
      cerebro.run()
      

      Output
      2020-09-01T23:59:59.999989, ---next len 1 - counter 1
      2020-09-02T23:59:59.999989, ---next len 2 - counter 2
      2020-09-03T23:59:59.999989, ---next len 3 - counter 3
      2020-09-04T23:59:59.999989, ---next len 4 - counter 4
      2020-09-07T23:59:59.999989, ---next len 5 - counter 5
      2020-09-08T23:59:59.999989, ---next len 6 - counter 6
      2020-09-09T23:59:59.999989, ---next len 7 - counter 7
      2020-09-10T23:59:59.999989, ---next len 8 - counter 8
      2020-09-11T23:59:59.999989, ---next len 9 - counter 9

      1 Reply Last reply Reply Quote 0
      • Ravi Vidap
        Ravi Vidap last edited by

        Nobody using this feature? no one facing this issue?

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