Backtrader Community

    • 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/

    Issue using Jupyter w/ IB Data Store

    General Code/Help
    interactivebro ib broker store jupyter
    1
    1
    121
    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.
    • D
      dizzydes last edited by

      I tried this code:

      from __future__ import (absolute_import, division, print_function,
                              unicode_literals)
      import datetime
      import backtrader as bt
      
      # from __future__ import (absolute_import, division, print_function,
      #                         unicode_literals)
      # import backtrader as bt
      
      # LOGIN TO IB REQUIRED
      
      class St(bt.Strategy):
          def __init__(self):
              self.sma = bt.indicators.SimpleMovingAverage(self.data)
      
      def run(args=None):
      
          cerebro = bt.Cerebro(stdstats=False)
          cerebro.addstrategy(St)
          store = bt.stores.IBStore(port=7496)
          data = store.getdata(dataname='GBP.USD',
                               sectype='CASH',
                               fromdate=datetime.datetime(2019, 9, 11),
                               todate=datetime.datetime(2019, 9, 12),
                               timeframe=bt.TimeFrame.Minutes,
                               compression=5)
          cerebro.adddata(data)
          cerebro.addstrategy(St)
          cerebro.run()
      
      if __name__ == '__main__':
          run()
      

      And get this as a response to the cell:

      Server Version: 76
      TWS Time at connection:20210103 17:14:29 Greenwich Mean Time
      

      The kernel stays running for a bit (its latest version) and then no new data comes before it stops. The above message is also what comes before the dataframe when I simply print the IB data it is working fine.

      But when I try to produce an indicator/backtest on it; nothing happens. Any ideas on the issue? As IBStore is built in would backtest usually know which columns to use or should I be matching them as if its CSV?

      Thanks

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