How to connect to ib_sync in Google Colab

214 Views Asked by At

How do you successfully set up an ib_insync connection in Google Colab?

Have tried:

pip install ib_insync

which runs successfully. then:

from ib_insync import * 
util.startLoop() 
ib = IB()
ib = IB( ib.connect('127.0.0.1', 7497, clientId=1)

Which results in:

API connection failed: ConnectionRefusedError(111, "Connect call failed ('127.0.0.1', 7497)")
Make sure API port on TWS/IBG is open

I have seen other related questions indicating one needs to set up a local runtime (colab reference document), however, I have not been able to successfully run this code (specifically receive an invalid syntax error when I get to step to run jupyter serverextension enable --py jupyter_http_over_ws in colab. I normally access ib_insync via jupyter lab.

Thanks for considering

0

There are 0 best solutions below