Guide 1.4
Beginner, 6 min read. Checked with Scalpel 1.14.0 on .

In short
Scalpel reaches your Interactive Brokers account through TWS or IB Gateway running and logged in on the same computer. Enable the API in that program, and make its socket port match Scalpel's (Settings > Connection > Port: 7497 by default; IB Gateway uses 4001). When they match, the IBKR pill in the bottom-left corner turns green and reads Connected. Until then, a banner under the header tells you what Scalpel found and offers a one-click fix.
Scalpel has no data feed of its own and never asks for your IBKR password. Everything it shows (quotes, Level 2, the tape, charts, IBKR's scanner, the news on your account) and every LIVE order goes through the API socket of the IBKR program you already use. That is also why there is nothing else to pay for: no separate data feed, no charting subscription.
Before you start
They are the same program underneath. IB Gateway is TWS without the trading screens: it uses far less memory and serves the same API. Interactive Brokers allows one trading-platform session per username, so logging in to TWS, IB Gateway or IBKR Desktop signs the others out (after asking). That gives three ways to run:
| Setup | Run | Good for |
|---|---|---|
| Scalpel instead of TWS | IB Gateway only | The lightest setup; Scalpel is your only trading screen |
| Scalpel alongside TWS | TWS with the API on | Keeping TWS's own windows; costs nothing extra |
| Both fully open at once | TWS on one username, IB Gateway on a second | Two independent logins. Add the second user in Client Portal; market data is billed per username, so it needs its own subscriptions |
Either program asks for two-factor approval on your phone at login and logs you out once a day unless you set auto-restart in its Lock and Exit settings. IB Gateway has no trading screen, but it is not unattended: it still needs those logins.
Each program listens on a socket port, and the number depends on the program and on whether you logged in to a live or a paper account:
| Program | Live login | Paper login |
|---|---|---|
| TWS | 7496 | 7497 |
| IB Gateway | 4001 | 4002 |
Scalpel starts on 7497. Log in with your real username: Scalpel's own SIM mode does the paper trading, against live data, so you do not need IBKR's paper account. That means a live TWS login usually listens on 7496 while Scalpel expects 7497. Change either side, or let the banner switch Scalpel over for you (below).
Start the program, log in and approve the login on your phone. Wait until it is fully up: TWS shows its main window, IB Gateway its status window.
In TWS, open the global configuration and go to API > Settings. Tick Enable ActiveX and Socket Clients, untick Read-Only API if you will ever trade LIVE, and note the Socket port. IB Gateway has the same page under Configure > Settings > API > Settings, with the socket always on. Every option is in guide 1.5.
In Scalpel, open Settings (Ctrl+,), then Connection. Under IBKR TWS (stocks: market data + orders), leave Enabled ticked and Host at 127.0.0.1, and set Port to the program's socket port: 7497 or 7496 for TWS, 4001 or 4002 for IB Gateway. Click Apply. Scalpel reconnects straight away, no restart.
The status bar along the bottom starts with the IBKR pill. It goes amber Connecting, then green Connected. Within a second or two the trader desks fill with quotes, Level 2 and the tape, the scan desk (desk 1 on a new install) starts listing movers once the IBKR scanner has results, and the voice says the link is up.
| Pill | Colour | Meaning |
|---|---|---|
| Connected | Green | Data and orders are flowing |
| Connecting | Amber | Scalpel is trying; it retries by itself, every second at first and backing off to every 20 seconds |
| Disconnected: and a reason | Red | The last attempt failed; the reason comes from the connection |
| Off | Grey | You switched the link off. Scalpel stops retrying and hides the banner |
Click the pill to switch the link off or back on. Off is handy when you close TWS on purpose for the evening; it is remembered across restarts, so switch it back on next session. If a working connection drops, you get an IB connection lost toast and a spoken warning.
While the link is down, Scalpel checks every 5 seconds which IBKR program is answering on this computer, on 7497 and 7496 for TWS and 4001 and 4002 for IB Gateway, and puts the answer in a banner under the header. There are four cases.
The right program, on its other port. Typical for a live TWS login on 7496. Click Use port 7496: Scalpel saves the new port and connects.
The other program is running. You set Scalpel up for TWS but started IB Gateway, or the other way round. Click Use IB Gateway (or Use TWS).
The program is up but will not let Scalpel in. The port answers but the API handshake fails: usually TWS is showing a window asking whether to accept the connection, or its API settings do not allow connections from this computer. Check the API settings (guide 1.5, guide 13.2).
Nothing is running. If TWS or IB Gateway is installed in its usual place, the banner offers Start IB Gateway and Start TWS. Scalpel starts it; you log in, and Scalpel connects by itself.
The X at the end of the banner hides it until the link next drops.