Give an AI agent IBKR paper trading access (TWS API or Web API)
✓ Written from official docs · checked 2026-10-17
Point your own agent or bot at an Interactive Brokers paper account instead of live money: paper logins, API settings, ports and a read-only switch. Steps from IBKR's API docs.
1. Get paper credentials
IBKR paper accounts belong to an approved IBKR Pro account and have their own username and password, separate from your live login. Your agent should only ever get the paper login.
2. Pick the API: TWS API or Web API
TWS API: your agent's code connects to Trader Workstation or IB Gateway running on your machine. Web API: your agent calls REST endpoints through the Client Portal Gateway. Both work with paper accounts.
3. TWS or IB Gateway: log in to paper and enable the API
- Start TWS or IB Gateway and log in with the paper username.
- In TWS, open the API settings and tick Enable ActiveX and Socket Clients (IB Gateway has it on by default).
- Keep Read-Only API ticked until you actually want the agent to place paper orders. It allows data and account reads but blocks orders.
- Keep connections local: allow only 127.0.0.1 as a trusted IP.
4. Connect the agent to the paper port
Default paper ports are 7497 for TWS and 4002 for IB Gateway (live is 7496 and 4001). Have your agent connect to 127.0.0.1 on the paper port, for example app.connect("127.0.0.1", 7497, 0) with the official ibapi client. A wrong port is the most common way to hit the live account by accident.
5. Or the Web API: log in to the gateway with paper credentials
Run the Client Portal Gateway, sign in with your paper username, then initialise the brokerage session with POST /v1/api/iserver/auth/ssodh/init before calling trading endpoints.
6. Verify it's paper before any order
Have the agent fetch account details and check that it's the paper account before it sends an order. Keep "Read-Only API" on while you test prompts and tools.
FAQ
What about IBKR's own MCP connector?
IBKR's AI Integration (MCP) is a different route: per our listing, the AI drafts order instructions and you place each one yourself on an IBKR platform. This guide is for agents or bots you run yourself through the TWS API or Web API.
Do I need a funded live account?
IBKR says paper accounts come with an approved IBKR Pro account. Check IBKR's current requirements before you plan around it.
Sources
- IBKR: Paper trading account
- IBKR Web API: Using a paper account
- IBKR TWS API: Initial setup
- IBKR Campus: Installing and configuring TWS for the API
Related guides
- How to connect Claude to Alpaca via MCP
- How to connect Claude (or any MCP client) to Interactive Brokers
- How to connect Claude to the tastytrade MCP server
- How to connect Claude (and other AI agents) to the Robinhood Trading MCP
- How to connect Claude to TradeStation MCP
- How to connect Claude (and other AI apps) to the Public hosted MCP server
- Connect ChatGPT, Cursor or Claude Code to Interactive Brokers (IBKR MCP)
- Set up a 3Commas or Bitsgap bot with a safe exchange API key (no withdrawals, IP whitelist)
- Run Freqtrade in dry-run mode (paper trading with a simulated wallet)