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

Historical testing with IB

  • I attempted to connect to an Interactive Brokers data feed to backtest a strategy of mine.

    My code is below:

    ibstore = bt.stores.IBStore(host='', port=7497, clientId=3921)
    data = ibstore.getdata(dataname=ticker_name, historical=True, fromdate=datetime(2000, 1, 1), todate=datetime(2016, 12, 31), timeframe=bt.TimeFrame.Seconds, compression=5)
    print("---- Starting Backtest ----")
    print("---- Plotting Results ----")

    When I run, I get the following error:

    Traceback (most recent call last):
    File "<PATH_TO>/", line 62, in 
    File "/Users/Tim/miniconda3/lib/python3.5/site-packages/backtrader/", line 665, in plot
    File "/Users/Tim/miniconda3/lib/python3.5/site-packages/backtrader/plot/", line 707, in show
    AttributeError: 'Plot_OldSync' object has no attribute 'mpyplot'

    Is backtesting with IB officially supported? If so, where is my code incorrect?

  • administrators

    Is backtesting with IB officially supported?

    This is an open source packages. "Officially" may not be the right description. Yes, you can connect TWS and download data. It is seen as another data feed.

    Your code seems to fail here:

    which seems to indicate matplotlib may be missing.

    From the docs Docs - Installation

    Additional requirements if plotting is wished:

    Matplotlib >= 1.4.1

    It may work with previous versions, but this the one used for development

Log in to reply