ib_insync client - Peer closed connection

1.2k views Asked by At

I am using the great package ib_insync for building a project with IB. I am getting some live ticker data as follows (pseudo code):

await self._ib_instance.connectAsync(host=self._host, port=self._port, clientId=100, readonly=True)

for contract in contracts:
    self._ib_instance.reqMktData(contract)
sleep(2)

for ticker in tickerEvent:
   print(ticker)

Basically I insert to a tickerEvent 5 K contracts and then listen to ticker data. And it works just perfect, but with the lapse of time (no pattern, always different time intervals) like 5 mins or 50 mins I get the error:

client - Peer closed connection

I found in the docs this error. But I do not know how to handle it? How to catch it? I try to catch it and reconnect, but it did not help!

Please help to solve this issue!

1

There are 1 answers

1
misantroop On

The number of contracts you can reqMktData for simultaneously is limited. 5000 contracts is not realistic without purchasing the required Booster Packs.

https://interactivebrokers.github.io/tws-api/market_data.html

By default, every user has a maxTicker Limit of 100 market data lines and as such can obtain the real time market data of up to 100 instruments simultaneously. This limit however can be further extended either through the purchase of quote booster packs or by increasing the equity and/or commissions of the user's account.