erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 775 forks source link

Market Data Disconnect with 0.9.62 on Ubuntu Linux 18.04 #306

Closed wardster-ai closed 4 years ago

wardster-ai commented 4 years ago

I've recently developed and deployed a stock trading app based on this wonderful framework. (Thanks Ewald!!) After a bit of testing locally on my Mac I deployed to the Google Cloud on Ubuntu 18.04 Linux. I set up a Gnome Desktop and TWS and installed all the supporting libraries in my server in including the latest patch of ib_insync (0.9.62). The IB app seemed to connect fine, the market data connections initialized, but after a couple of trades my app would disconnect. It didn't error out but I would simply see the following message in the logs:

2020-10-20 09:31:09,012 - ib_insync.wrapper - INFO - Warning 2103, reqId -1: Market data farm connection is broken:usfarm

Then the TWS app would basically freeze. I ran the app a few times in the debugging process. Sometimes after this message I would see a message in the logs that the connection had been reestablished but all processing with the TWS and the API would stop.

I tried several things to resolve the issue (changing versions of TWS and the JDK's) but the resolution occurred when I realized I had the previous version of ib_insync on my dev environment vs. the latest on Ubuntu. Once I rolled this back my app seems to be fully connected again and doesn't drop once trading starts.

Let me know if you need more info to duplicate or if there is logging I can enable to provide more info.

erdewit commented 4 years ago

2020-10-20 09:31:09,012 - ib_insync.wrapper - INFO - Warning 2103, reqId -1: Market data farm connection is broken:usfarm

This is a common error; It affects the remote connection (TWS to IBKR). IB-insync uses the local API connection and can't do anything about that.