Brokers
Discord Get started

Brokers

Interactive Brokers

Connect Interactive Brokers to TradeLabs by running TWS or IB Gateway locally with the API enabled, then adding the account in the Brokers page.

Interactive Brokers connects through the Trader Workstation (TWS) or IB Gateway software running on the same computer as TradeLabs. TradeLabs talks to it over a local loopback connection, so there is no API key to paste. Keep TWS or IB Gateway signed in and running, and TradeLabs connects to it.

What it tradesSupported
StocksYes
OptionsYes
SpreadsYes
FuturesYes
RSA, crypto, memecoinsNo

TradeLabs uses port 7496 for a live account and 7497 for a paper account. Whichever mode you pick when adding the account, TWS or IB Gateway must be running in the matching mode.

Note

Interactive Brokers supports one connection per machine, so you add a single Interactive Brokers account.

Before you start

  • An Interactive Brokers account, funded on the Interactive Brokers website.
  • An options market-data subscription (OPRA) on the Interactive Brokers side if you want real-time options quotes.
  • TWS or IB Gateway installed on the same computer as TradeLabs.
  • The TradeLabs Companion installed and running.
Note

If your balance is under $25,000, a cash account avoids Pattern Day Trader restrictions. Cash or margin is up to you and does not change how TradeLabs connects.

Install TWS or IB Gateway

Download the IBKR Trader Workstation (TWS) or IB Gateway from the Interactive Brokers TWS download page and install the build for your operating system. Sign in and keep it running whenever you want TradeLabs to trade.

Enable the IBKR API

TradeLabs reaches Interactive Brokers through the TWS or IB Gateway API on a local socket. Enable the API in TWS so TradeLabs can connect.

Enable the IBKR API in TWS or IB Gateway 1 OPEN API Settings In TWS: File, Global Config, API, Settings. 2 ENABLE Socket Clients "Enable ActiveX and Socket Clients". 3 TRUST LOCALHOST 127.0.0.1 Add it to Trusted IPs. Note the port: 7496 live, 7497 paper. 4 CONNECT In TradeLabs, Host 127.0.0.1 Port 7496 or 7497, Client ID 0. Keep TWS running. TradeLabs talks to TWS locally, so the software must be running with the API enabled whenever you trade.

Enable socket clients, trust localhost, and confirm the port for your mode.

Open the TWS API settings and:

  • Enable the socket clients option so external applications can connect.
  • Allow connections from the local machine (127.0.0.1).
  • Confirm the socket port matches your mode: 7496 for live, 7497 for paper.

Keep TWS or IB Gateway running and signed in whenever you want TradeLabs to trade.

Connect it in the app

Once TWS or IB Gateway is running with the API enabled, add the account in TradeLabs.

  1. Open the Brokers page, find the Interactive Brokers card, and click Add account.
  2. Set Mode to Live (real trading, port 7496) or Paper (practice, port 7497). Give the account a Label if you want a name that is easy to recognize.
  3. Click Save account. TradeLabs connects to TWS or IB Gateway and checks the connection on its own.

The Interactive Brokers connect formThe Interactive Brokers connect form Set Mode to Live (port 7496) or Paper (port 7497) to match how TWS or IB Gateway is running

To re-check the link later, open the account row menu and choose Check connection.

Heads up

Make sure the mode you pick here matches the mode TWS or IB Gateway is running in. A live account cannot reach a Gateway running in paper mode, and the reverse is also true.

Fixing common problems

  • Connection fails: confirm TWS or IB Gateway is running and signed in, the API socket clients option is enabled, and 127.0.0.1 is trusted.
  • Wrong port: the mode you chose in TradeLabs must match the port TWS or IB Gateway is listening on (7496 live, 7497 paper).
  • Options quotes missing: confirm your OPRA options market-data subscription is active on the Interactive Brokers side.