nautechsystems / nautilus_trader

A high-performance algorithmic trading platform and event-driven backtester
https://nautilustrader.io
GNU Lesser General Public License v3.0
1.7k stars 398 forks source link

Fix Interactive Brokers multiple gateway clients #1702

Closed dodofarm closed 3 weeks ago

dodofarm commented 3 weeks ago

This caused the exec-client to stop working. (or any second client being created through the gateway). This made the bot completely nonfunctional.

The factories use get_cached_ib_client, but since the port value was being set only on the first run of the function (due to the global GATEWAY variable). On the second run of the function, e.g. if another factory tried to create a new client, it was causing the port to be set to the default value None. This caused that a different client_key was created with the port value being None, as a result the code creates a new InteractiveBrokersClient with the port None, this obviously fails and the bot can't start the execution client.

CLAassistant commented 3 weeks ago

CLA assistant check
All committers have signed the CLA.