Tracking IB active orders and stop losses with Streamlit and TradingView

Xavier Escudero
4 min readApr 1, 2024

Continuing from the previous article, we’ll now delve into displaying the table of currently active orders alongside the corresponding stop loss lines on the symbol charts.

Retrieving active orders

When attempting to fetch active orders through the reqAllOpenOrders method with a specific client ID, we encounter an empty list as a result.

Referring to the documentation of ib_insync is mentioned:

reqAllOpenOrders(): Request and return a list of all open orders over all clients. Note that the orders of other clients will not be kept in sync, use the master clientId mechanism instead to see other client’s orders that are kept in sync.

So, how do we employ the master clientId mechanism?

In IB Gateway, navigate to the Configure menu, proceed to API > Settings and set a value for Master API client ID, for instance 100.

Then, adjust the code of connection to use this assigned clientId:

--

--

Xavier Escudero

Innovation enthusiast, passionate about automation in several fields, like software testing and trading bots