IB Gateway Connection

A few questions / comments regarding the IB Gateway:

  • Is the IB Gateway a persistent connection?

  • I know that it automatically restarts itself once / day but whenever I log into my computer (after it falls asleep) and I open a tab for the IB Gateway it shows the noVNC and Connect button which leads me to believe the connection was lost.

![Screen Shot 2024-07-18 at 9.48.29 AM|690x377](upload://rPuLsNROdDiqQcKxTwxy7Z5O9QM.png)
  • If the connection is not persistent how do I ensure the connection is not lost for intraday trading algorithms?

  • I ask about persistent connection and if it's based on a local configuration of my computer OR within my IBKR account setting because when I log into Trader Workstation outside of Quantrocket when my computer goes to sleep and I log back on I receive a notification from Trader Workstation that my data connection was lost.

Any insights or if you can point me to documentation around this issue that would be great.

Thanks.

@Brian related to the IB Gateway persistence I'm struggling to connect two IB Gateways at once. I've set up two Users with separate UserIDs and Passwords and have not been successful in connecting both gateways (IBG1 and IBG2) at once. In my docker compose-override file I have one User in IBG1 and the second User in IBG2. I frequently receive the below error in the IB Gateway GUI.

If your computer goes to sleep you won't have an internet connection. To run any unattended tasks, your computer must remain awake.

1 Like

This error message is from IBKR and means you must log in with your paper trading credentials, which can be obtained in Client Portal, not your live credentials in paper mode.

1 Like

@Brian I was able to resolve the IBGateway issues, thanks for your help. I'm now downloading historic Futures Data from IBKR. A few questions:

  • Is there an easy way to determine when the historic price data collection is complete?
  • I was seeing completion reports in Flightlog but then started receiving error messages. I've pasted below snippets of the logs I started to receive.
2024-07-24 04:51:11 quantrocket.ibg1: ERROR   File "/opt/conda/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
2024-07-24 04:51:11 quantrocket.ibg1: ERROR     resp = self.send(prep, **send_kwargs)
2024-07-24 04:51:11 quantrocket.ibg1: ERROR            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24 04:51:11 quantrocket.ibg1: ERROR   File "/opt/conda/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
2024-07-24 04:51:11 quantrocket.ibg1: ERROR     r = adapter.send(request, **kwargs)
2024-07-24 04:51:11 quantrocket.ibg1: ERROR         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-07-24 04:51:11 quantrocket.ibg1: ERROR   File "/opt/conda/lib/python3.11/site-packages/requests/adapters.py", line 532, in send
2024-07-24 04:51:11 quantrocket.ibg1: ERROR     raise ReadTimeout(e, request=request)
2024-07-24 04:51:11 quantrocket.ibg1: ERROR requests.exceptions.ReadTimeout: HTTPConnectionPool(host='houston', port=80): Read timed out. (read timeout=120)
2024-07-24 04:51:11 quantrocket.ibg1: ERROR 
2024-07-24 04:52:21 quantrocket.ibg1: WARNING ibg1 still not started, will stop and start again
2024-07-24 04:52:21 quantrocket.ibg1: INFO stopping ibg1
2024-07-24 04:52:33 quantrocket.ibg1: INFO starting ibg1
2024-07-24 04:55:36 quantrocket.ibg1: WARNING ibg1 still not started, will stop and start again
2024-07-24 04:55:36 quantrocket.ibg1: INFO stopping ibg1
2024-07-24 04:55:48 quantrocket.ibg1: INFO starting ibg1
2024-07-24 04:58:04 quantrocket.account: WARNING error collecting account balances, will try again shortly: IBKR account summary download not complete after 10 seconds
2024-07-24 04:58:38 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 04:58:58 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 04:59:04 quantrocket.account: WARNING error collecting account balances, will try again shortly: IBKR account summary download not complete after 10 seconds
2024-07-24 04:59:18 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 04:59:41 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 05:00:02 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 05:00:04 quantrocket.account: WARNING error collecting account balances, will try again shortly: IBKR account summary download not complete after 10 seconds
2024-07-24 07:13:31 quantrocket.blotter: WARNING IBKR executions not received from ibg1 in a timely manner, will try again shortly
2024-07-24 07:13:41 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 09:16:46 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
2024-07-24 11:59:31 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
2024-07-24 11:59:41 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
2024-07-24 15:11:08 quantrocket.blotter: WARNING IBKR open orders not received in a timely manner, will try again shortly
2024-07-24 15:11:18 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
2024-07-24 15:11:28 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 07:13:31 quantrocket.blotter: WARNING IBKR executions not received from ibg1 in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 07:13:41 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 09:16:46 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
 quantrocket-realtime-1|announcing my loyalty to the Emperor...
 quantrocket-realtime-1|Wed Jul 24 09:50:25 2024 - [emperor] vassal /etc/uwsgi/uwsgi.ini is now loyal
  quantrocket-jupyter-1|[I 2024-07-24 09:50:32.258 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
 quantrocket-realtime-1|announcing my loyalty to the Emperor...
 quantrocket-realtime-1|Wed Jul 24 09:51:42 2024 - [emperor] vassal /etc/uwsgi/uwsgi.ini is now loyal
  quantrocket-jupyter-1|[I 2024-07-24 09:52:32.335 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
  quantrocket-jupyter-1|[I 2024-07-24 10:00:33.239 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
  quantrocket-jupyter-1|[I 2024-07-24 10:02:34.231 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
  quantrocket-jupyter-1|[I 2024-07-24 10:04:34.303 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
  quantrocket-jupyter-1|[I 2024-07-24 10:06:34.375 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
  quantrocket-jupyter-1|[I 2024-07-24 10:08:34.441 ServerApp] Saving file at /Interactive_Brokers_Data.ipynb
quantrocket-flightlog-1|2024-07-24 11:59:31 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 11:59:41 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 15:11:08 quantrocket.blotter: WARNING IBKR open orders not received in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 15:11:18 quantrocket.blotter: WARNING IBKR executions not received from ibg2 in a timely manner, will try again shortly
quantrocket-flightlog-1|2024-07-24 15:11:28 quantrocket.blotter: WARNING IBKR positions not received in a timely manner, will try again shortly

Further, both the ibg1 and ibg2 GUIs are showing the following:

![Screen Shot 2024-07-24 at 11.37.41 AM|690x219](upload://svoJA6KQSCAT0OShWGjn7KRRrIL.png)

Any guidance would be appreciated.

Thanks.