pythontwsib-api

Encounter error "IB API required" when IB API is installed


I am trying out this new python package ib_insync.

https://github.com/erdewit/ib_insync

I ran the python script below;

from ib_insync import *

ib = IB()
ib.connect('127.0.0.1', 7496, clientId=1)

contract = Forex('EURUSD')
bars = ib.reqHistoricalData(contract, endDateTime='', durationStr='30 D', barSizeSetting='1 hour', whatToShow='MIDPOINT', useRTH=True)

# convert to pandas dataframe:
df = util.df(bars)
print(df[['date', 'open', 'high', 'low', 'close']])

I encountered the error IB API from http://interactivebrokers.github.io is required.

I have already installed IB API ver 9.73.06 under C:\TW_API folder. I am using Windows 10 and anaconda python v3.6 .

Here is a snapshot of my TWS API settings;

enter image description here


Solution

  • I found the answer to my own question. The problem was that ib-api python module was not installed into the python version that I am using

    There is a README.md found in C:\TW_API\source\pythonclient Following the instructions, I ran the following commands;

    $ python setup.py bdist_wheel
    $ python -m pip install --user --upgrade dist/ibapi-9.73.6-py3-none-any.whl
    

    My python script runs normally without error now.