IBKR: setting up IB Gateway
Taji speaks to an IB Gateway the user runs on their own machine; the Gateway holds the IBKR login and Taji never sees the password. Taji finds the Gateway itself: nobody types a port or a client id. Walk the user through these one at a time, confirming each before the next. Skip to step 6 when the Gateway is already running.
- They need an opened, funded IBKR Pro account (paper included) with 2FA on IB Key or SMS.
- Install IB Gateway, the Stable build for their OS, from IBKR's download page (search interactivebrokers.com for the current URL).
- Log in choosing IB API and Paper Trading (Live Trading for a live link), and approve the 2FA.
- Configure → Settings → API → Settings: the port is 4002 on paper by default (4001 live), and leave it; "Read-Only API" is ticked by default: untick it, else no orders; keep "Allow connections from localhost only" on; keep 127.0.0.1 under Trusted IPs (a fresh install lists it). TWS users also tick "Enable ActiveX and Socket Clients".
- Leave the Gateway running and logged in: Taji trades through it, so a closed Gateway is an unbound row.
- Make the link call
link_chooseanswered again (live: trueonly after the user's yes); the user approves it in Taji's window. It answers the linked row or a word:not_running(no Gateway on this env's port: start it and log in),unreachable(accept the Gateway's connection prompt or keep 127.0.0.1 under Trusted IPs),env_mismatch(the Gateway on this env's port is logged into the other env),vault(open the vault first).
When it breaks
- One IBKR login per username at a time: logging into TWS, Client Portal or mobile with the same username drops the Gateway.
- A paper account has its own username, so paper and live can run as two Gateways, on 4002 and 4001; each link looks only at its own env's ports.
- The Gateway restarts daily and IBKR asks for a manual re-login weekly. A row reading
bound: falseusually means the Gateway is logged out: have the user log it back in.