> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Interactive Brokers

Trade stocks, options, futures and more at Interactive Brokers through the Gateway or TWS you keep logged in.

## Before you link

You need IB Gateway running and logged in, with "Read-Only API" off; there is nothing to type, and the Gateway holds the login. Paper trading requires a funded IBKR Pro account.

### Access

- No app registration. Gateway and TWS each take ≤32 API clients (docs architecture).
- One brokerage session per username, any platform; a second username (own market data) works around it (docs `web-api/authentication/multiple-sessions.md`); a Client Portal login on it breaks Gateway auto-reconnect.
- Unused: Client Portal Gateway (daily browser login); OAuth 1.0a (third parties); OAuth 2.0 (not for individuals).
- Paper: USD 1,000,000; permissions and market data mirror live; IB lists no VWAP, auction, RFQ or peg-to-market (VWAP algo acked 2026-10-01); fills and stops simulated off top of book (`ibkrguides.com/clientportal/aboutpapertradingaccounts.htm`).

### Fees and data subscriptions

- Live API data is paid; free delayed (15–20 min, `reqMarketDataType(3)`) covers `reqMktData` and `reqHistoricalData` only (docs `market-data-delayed`).
- Needs USD 500 equity plus fees, the signed API Market Data Acknowledgement, a non-professional self-declaration (default Professional) (docs market-data-subscriptions); monthly, not pro-rated.
- Prices: `interactivebrokers.com/en/pricing/market-data-pricing.php`, re-fetched when quoted.
- 100 market-data lines default; a live user's data serves one paper user.

## Link

Start `ibkr-paper` (simulated money) or `ibkr-live` (real money: every order through this Gateway is real) from Connections in the window, or run `taji-link ibkr-paper` or `taji-link ibkr-live`. Neither takes a field: Taji finds the IB Gateway on this device and seals where it listens in the vault.

### Linking

`ibkr-paper` and `ibkr-live` steps, each fetched 2026-11-18 (page, controls, who). `yours`: password, code or money; else agent. `fq` = `interactivebrokers.com/support/faq/content/`; `lesson` = `interactivebrokers.com/campus/trading-lessons/installing-configuring-tws-for-the-api/`; `docs` pages read as `.md`.

- `account`, `interactivebrokers.com/en/home.php`: "Open Account", "Start Application" (`ndcdyn.interactivebrokers.com/Universal/Application`); form fields unsourced. The API needs a funded, opened IBKR Pro account (docs `tws-api/doc/notes-limitations/requirements`) and 2FA. Live also funds: "Fund Your Account". Yours: identity, password, money.
- `paper`, Client Portal on the live login (`ndcdyn.interactivebrokers.com/sso/Login`): User menu (head-and-shoulders icon, top right), "Settings", "Account Settings" > "Account Configuration" > "Paper Trading Account"; create a User ID and Password, "Continue" (`fq`/37128282). Needs a funded live account. Yours: login, new password.
- `issued`, email: a request in by 4:00 PM EST on a business day is processed the next one, then emailed (`fq`/37128282). The same page then shows "Paper Trading Username", "RESET PAPER TRADING PASSWORD", "RESET" (`fq`/28229874). The wait is no one's; a reset is yours.
- `install`, `interactivebrokers.com/en/trading/ibgateway-stable.php`: tabs "Latest", "Stable" (no self-update); "Download" under "Apple Silicon (M-series)", "Apple Intel Processor", "Windows", "Linux (X86_64)", "Linux (ARM64)"; the .dmg or .exe opens an Install Wizard: defaults, "Next" (`lesson`). Current Stable or Latest only (docs requirements). Agent.
- `login`, the IB Gateway window: API Type "IB API", not "FIX CTCI" (`fq`/ib-gateway-41571362); username and password typed by hand (docs `tws-api/doc/download-tws`). Mode is picked before login: TWS's "Trading Mode" lists "Paper Trading" and "Live Trading" (`fq`/42719115), the Gateway's control unsourced; paper takes the paper username (`fq`/28229874). 2FA: IB Key, Handy Key, SMS, DSC+; not Security Code Card, Temporary Security Code Card, Online Code Card (docs `…/supported-two-factor-authentication-2-fa`). "Configure" > "Lock and Exit" > "Auto Restart" skips the daily login (`fq`/ib-gateway-41571362); Monday's is manual (docs `tws-api/doc/tws-settings/daily-weekly-reauthentication`). Yours: password, 2FA code.
- `api`, Gateway "Configure" > "Settings" > "API" > "Settings" (`lesson`): check "Enable ActiveX and Socket Clients"; uncheck "Read-Only API"; "Socket Port" defaults 4002 paper, 4001 live; "Apply", "OK". Else a dialog "Accept incoming connection attempt from `<IP Address>`" asks per connection; "Trusted IPs" > "Create" takes one address, no subnet; "Allow connection from localhost only" is for remote use (docs `tws-api/doc/connectivity/remote-tws-api-connections-with-trader-workstation`). Agent; accepting the dialog is a click.

Taji dials `127.0.0.1`: paper 4002 then 7497, live 4001 then 7496; per port client ids 1701, 1703, 1705, the next on 326 (another client holds it; all held is `client_id`); nothing listening is `not_running`; the other kind of account `env`; a failed handshake `unreachable`.

## What you get

You trade your IBKR account from the window and your agent reads it: Taji reads your balances, positions and orders. What it reads of IBKR's market data, down to each field: [Interactive Brokers coverage](https://docs.taji.is/reference/coverage/ibkr.md); what IBKR serves that it does not yet: [Offered, not read](https://docs.taji.is/catalog/ibkr/architecture.md#offered-not-read).

## Behaviour and limits

Read 2026-09-28/29, paper-measured where dated.

P = any IB-owned citation (doc, spec, SDK) and any unmarked, undated line; S = community; U = inferred. `docs` = `ibkrcampus.com/docs/…`; `zip` = `interactivebrokers.github.io/downloads/twsapi_macunix.1050.02.zip` (Stable; versions read off `download2.interactivebrokers.com/installers/tws-api/index.html`: Stable 1050.02, Latest 1051.01); `spec` = `api.ibkr.com/gw/api/v3/api-docs`.

Design choice: TWS API to the user's Gateway via MIT `ibapi` (S); no IB code ships. The download page says "Non-Commercial", no redistribution; the 10.50 zip's `LICENSE` is GPLv3 (`interactivebrokers.github.io`; zip); implementing the protocol is sanctioned (docs `tws-api/doc/introduction.md`).

### Transport and limits

- Global pace, per connection: market-data lines ÷ 2 per second, 50/s at 100 lines; lines scale with commissions, equity and Quote Booster packs, unreadable over the API; error 100; a third breach disconnects (docs `pacing-limitations`, `market-data-lines`).
- History: no identical request within 15 s; fewer than 6 per contract, exchange and tick type in 2 s; ≤60 per 10 min, stated for bars ≤30 s, a BID_ASK request counting 2 (docs `pacing-violations-for-small-bars-30-secs-or-less.md`); real-time bars opens under the same 60 per 10 min (docs `request-real-time-bars.md`); ≤50 open history requests ("The maximum number of simultaneous open historical data requests from the API is 50", `interactivebrokers.github.io/tws-api/historical_limitations.html`, 2026-10-31). Tick-by-tick: ≤1 per instrument per 15 s.
- ≤20 active orders per contract per side per account (legacy `order_limitations`).
- Paper, 2026-10-02: 120 requests in a burst, or 2 clients at 30/s, answered in one-second waves, no 100; ~59 `reqHeadTimeStamp` answered, then silence for 105 s, no 162; the 101st data line answered 101; 21 resting orders on one client accepted.
- Requests before `nextValidId` may drop. `orderId` rises per client: one ≤ a prior one is 103 "Duplicate order ID"; an open order's id, same client, modifies; no lookup by id, only the `reqOpenOrders`, `reqCompletedOrders` and `reqExecutions` lists; `orderRef` a free tag (D, interactivebrokers.github.io/tws-api/ `message_codes`, `modifying_orders`, `classIBApi_1_1Order`, read 2026-11-02).

### Data

| Product | Call |
|---|---|
| bars | 1 s–1 month; 1 s ≤2000 S a request, others ≤1 y; `TRADES` (crypto `AGGTRADES`, forex `MIDPOINT`) adjusts splits; daily `ADJUSTED_LAST` splits and dividends, spinoffs unstated (U), a window ending now; live 5 s `TRADES`, on L1 |
| trades, quotes | tick-by-tick Last/AllLast/BidAsk/MidPoint, no real-time options or combos, indices on CME only; historical ticks ≤3 y, ≤1000 a request; live quotes delayed unsubscribed; live prints `Last`, on L1 |
| extended, 24h | `useRTH=0` for 04:00–20:00 ET; `24h` adds the night off the `OVERNIGHT` exchange |
| depth | L2, 3 streams at default lines, a separate subscription (NASDAQ depth: TotalView-OpenView, outside L1) |
| news, earnings | subscribed; earnings is WSH (zip) |
| fundamentals | absent from the 10.50.02 and 10.51.01 zips |
| calendar | `tradingHours`/`liquidHours` weeks ahead |
| statistics | generic ticks 165 misc stats, 233 RTVolume, 236 shortable, 411 historical volatility, 100 and 101 an underlying's option volume and open interest (ticks 29, 30, 27, 28), 106 implied volatility, 588 futures open interest, 225 auction values, 49 halted, 456 IB dividends (`interactivebrokers.github.io/tws-api/tick_types.html`, 2026-12-04) |

- Live 5 s bars, paper, 130 s in RTH 2026-11-02: AAPL, SPX and the SPY 0DTE call nearest the money each 420 realtime ("No market data permissions"), 354 after `reqMarketDataType(3)`; no bar came. Earlier: NQZ26 option 420 "CME FOP" (2026-11-01). Delayed `reqMktData` streamed price, size and string ticks on all three in 20 s, the option also 23 option computations.
- Live future-option chain, paper 2026-11-01: `reqMktData` on contracts built from a `reqSecDefOptParams` row (no conid) opens: Delayed, 10167, request parameters.
- Tiers, paper 2026-11-07, one Monday-Friday week: 5m and 30m align in every served class; 1h for a future (Globex 18:00) and extended equity (04:00). Misaligned: regular equity, option and index 1h at 09:30, 10:00, 11:00 …, 4h 09:30, 11:00, 15:00; extended 4h 04:00, 07:00 …; future 4h 18:00, 19:00, 23:00 …. An AAPL option ran to 16:15 ET, once from 08:40. EUR/USD and BTC/USD history: 162 "No market data permissions".
- L1 sampled: US stocks, futures and indices 250 ms, options 100 ms (docs `market-data-update-frequency.md`).
- Forming day: snapshot ticks 14 open, 6 high, 7 low, 4 last, 8 volume, in round lots (US stocks ×100, docs `tick_types`); the delayed 72, 73, 74 carry no open (76 "not currently available"), so a delayed tier serves none; open before the session opens is the day before's.
- No history: bars ≤30 s past 6 months, futures expired >2 y, expired options and FOPs, option end-of-day, delisted securities (docs `unavailable-historical-data.md`).
- 2026-09-30 paper: equity and future tiers delayed; AAPL 1m, a week: 1934 bars; option daily bars 162 at any span (EODChart); 322 past the open account-summary cap; NQZ26 lists one conid on CME and QBALGO; STK generic ticks (else 321): 100,101,105,106,165,221/220,225,232/221,233,236,258/47,292,293,294,295,318,375,411,456/59,460,499,577; WSH 10276, scanner 492, `abovePrice` 162.
- 2026-09-30 paper: crypto history refuses `TRADES` (10299); no PAXOS data (162 history, 354 snapshot and 5 s bars); BTC on PAXOS tick 0.25, size 1e-8; matching-symbols BTC lists ZEROHASH, OSL, PAXOS. SPX: IND, CBOE; 1m and daily history, volume 0; delayed snapshot (10167) last only; 5 s bars 420 (no CBOE IND permission). Crypto LMT IOC and `Minutes` (IB-cancelled pre-reprice), $5 `cashQty` MKT: acked.

### Orders

Web API `tif` enum (spec).

| Class | Kinds | TIF | Sessions | Sizing | Multi-leg |
|---|---|---|---|---|---|
| equity | market, limit, stop, stop_limit, trailing_stop, moc, loc, moo/loo (market/limit on `tif="OPG"`), bracket, oto, oco | day, gtc, ioc, fok; gtd | `extended` = `outsideRth`, `24h` adds `includeOvernight`; a limit alone | paper refuses `cashQty` (10244), fractions (10243), 2026-10-01 | `BAG` combo |
| option | market, limit, stop, stop_limit, bracket, oto, oco | as equity | extended limit acked 2026-10-01 | — | `BAG` |
| future | as option | as equity | — | — | `BAG` |
| future option | as future; `FOP` (zip `ContractSamples.py`) | as equity | — | — | — |
| crypto | PAXOS market, limit (`tws-api/cryptocurrency.html`) | ioc; limit also `Minutes` (5-min) | — | market buy: `cashQty` | — |

- Conditions: price, time, margin, volume, change, execution (zip).
- Algos (`interactivebrokers.com/en/trading/ordertypes.php`, 2026-09-30): FUT AD, Adaptive, Dark Ice, four PoVs, TWAP, VWAP, four QB algos; FOP AD alone.
- 2026-09-30 paper, AAPL on SMART: takes DAY, GTC, IOC (IB-cancelled), OPG, DTC, GTD date; refuses FOK and AUC (201; FOK on FUT/CME too; FOP inherits FUT's TIFs), GTX (10052, OPT too), GTD instant before open, TRAIL LIMIT without `trailStopPrice` (321), ISLAND auction, direct NYSE route (10311, then 201); 201 also discards ISLAND non-display, marketable-to-BBO, both IBKRATS pegs.
- 2026-09-30 paper: FUT GTD `yyyymmdd 16:00:00 US/Eastern` is 343 (STK took it), IB's UTC `yyyymmdd-hh:mm:ss` acked 2026-10-01; active times (AD's too) take `hh:mm:ss` UTC, no date (10315); duration needs GTD (10272), no date (10273).
- 2026-09-30 paper, AAPL SMART limit: min qty 10256, not held 10297, sweep to fill 10267 (last two OPT too; all three FUT 2026-10-01); IBKRATS PEG BEST/MID refuse min trade qty (10302); PEG MKT and PASSV REL 387; block needs 50 (117); display size a lot multiple (201), at most the order's (10020); active window a scale or AD order (201); ArrivalPx and ClosePx need `maxPctVol` (441); VOL what-if's stock range 453 on delayed data.
- 2026-10-01 paper (`plugins/ibkr/tests/live.rs`): AAPL and its calls took every word bar the refusals above; MOC acked 15:40 ET. FUT and FOP rested activate*, adjust, route; FUT also inactive, randomize, rules, show-only, trigger, MIT, nine algos on UTC times (Eastern 10314). Refused: FUT AON 10257, trail stop limit 321; FOP AON 10257; MNQ calendar `BAG` 110.
- 2026-10-08 paper, Gateway :4002: MNQZ26 and NQZ26 C43000 market round trips filled. No option market-data tier: no ask.
- Modify, every class (TWS API, Modifying Orders): `placeOrder` on an open order's `orderId` with its fields but the changed one; the docs name no class exception.
- Shorting: paper shorted MNQZ26 2026-09-30, AAPL 2026-10-01; crypto never (P: IB form 4249 §11, fetched 2026-09-30).

### Symbology and gotchas

- All keys on a conid, one per product × currency × market: AAPL on NASDAQ (docs `contract-i-ds.md`).
- Depth error 317 clears the book.
- A continuous future streams nothing (`NO_CONTINUOUS`).
- Paper 2026-11-02: `index:$NDX` "no security definition"; FOP bars mostly zero-volume.

Taji refuses:

- `auto_open_orders` binds client 0 only; other clients' rows list as `perm:`.
- No live news product; article bodies past 10 s answer `content: null`.
- No IB flag for shorting enabled, `add_liquidity`/`book_only`; strict `Gt`/`Lt`: IB's `is_more` is at-or-beyond; SSHORT is institutional only.

## Open

- >20 active orders/contract/side/account breach answer.
- Forming-day extended volume; `outsideRth`/`includeOvernight` (futures, FOP, crypto); option, future, FOP sizing; `BAG` FOP.
- Modify after partial fill; shorting (options, FOP, forex).
- Paper live-data tiers (`reqMktData`, 5 s bars, L2 depth, 15:50–16:00 ET imbalance); `WALK_EXERCISE` (OTM/ITM).
- Option statistics (ticks 24, 27 to 30): the unit of IV (IB states none; read as a fraction), whether an index (`SPX`) answers generic 100, 101 and 106, and the hours the ticks are sent.
- Concurrent WSH; non-CME roots (`CL`, `GC`, `ZN`); `DJI`, `RUT`; forex volume, depth; crypto dollar-limit, notional sell.

## References

- [Interactive Brokers: how it works](https://docs.taji.is/catalog/ibkr/architecture.md): the TWS API on its own, how Taji is built on it and why, with examples and the test commands.
