IBKR Paper Trading: Account Setup, API Ports and Limits

AI Summary: IBKR paper trading gives every funded Interactive Brokers client a simulated account that works with TWS, IB Gateway, the TWS API and the Web API. For developers it is the right place to test connections, order logic and reconnects, but fills are simulated from the top of the book, some order types are unsupported, and market data depends on how you share your live subscriptions. |
IBKR paper trading is Interactive Brokers’ simulated trading account. It runs on the same platforms as your live account (Trader Workstation, IB Gateway, Client Portal and IBKR Mobile) and it accepts API connections, so you can build and test an automated strategy without risking money. IBKR itself recommends testing all API programs in a paper environment before moving to production.
That makes the paper account the first stop for any team building on the Interactive Brokers API. But it is a simulator, not a copy of the live market. This guide covers how to get the account, how to connect your code to it, what behaves differently from live trading, and the tests we run before switching a system to a live account.
Key takeaways
You need a funded live IBKR account first. The paper account has its own username and password.
Paper sessions use their own default API ports: 7497 for TWS and 4002 for IB Gateway.
Fills are simulated from the top of the book. Some order types aren’t supported, and results are often better than live.
Market data comes from your live user’s subscriptions, if you share them. Otherwise it is delayed.
Treat paper as a test of your code, not of your strategy’s profitability.
What is an IBKR paper trading account?
According to IBKR, paper trading lets you use the full range of trading facilities in a simulated environment using real market conditions. You can learn order types, try new exchanges and products, and test strategies without risk.
A few facts worth knowing before you plan around it:
It requires a funded live account. IBKR’s FAQ says the paper trading account is only accessible once your live account has been funded.
It starts with USD 1,000,000. All customers start with USD 1,000,000 of paper trading Equity with Loan Value.
It has separate credentials. The paper username and password are different from your live login.
It is a different account. The paper account has its own account number, so your code must use the right one.
IBKR also offers a demo login in TWS (“Try the Demo”, using an email address) for people without an account. That demo isn’t tied to your account, so use the paper account to test your own setup.
How to get your IBKR paper trading login
IBKR’s steps for Client Portal are:
Log in to Client Portal with your live username and password.
Open the User menu (head and shoulders icon, top right) and choose Settings.
Under Account Settings, go to Account Configuration and click Paper Trading Account.
Note the paper trading username. Click RESET PAPER TRADING PASSWORD to set a password.
Use these credentials to log in to paper trading in TWS, IB Gateway, Client Portal or IBKR Mobile.
In TWS and IB Gateway, choose the paper option on the login screen. If you run IB Gateway in Docker, the image needs the paper credentials instead of the live ones. The gnzsnz/ib-gateway image, for example, has a TRADING_MODE setting that accepts paper, live or both. Our headless IB Gateway in Docker guide covers that setup in detail.
Resetting the paper balance
You can reset the paper balance from Client Portal: log in to the paper Client Portal, open Account Settings, and click the gear icon next to Paper Trading Account Reset. You can pick an amount different from the original, up to five times your production account value. IBKR says reset requests should be entered before 16:00 EST to take effect the next business day, so plan resets between test runs, not in the middle of one.
What matters most when setting up IBKR paper trading?
Easy Account Setup
Correct API Ports
Trading Limits
Risk-Free Testing
Connecting to the IBKR paper trading API
Both of IBKR’s main APIs work with paper accounts. For the TWS API (socket API), you log TWS or IB Gateway into the paper account and point your code at that session. For the Web API, IBKR says to log in to the Client Portal Gateway with your paper username, and the rest of the workflow stays the same.
IBKR paper trading ports
Ports are the most important difference in practice. IBKR’s defaults are:
Application | Live port | Paper port |
TWS | 7496 | 7497 |
IB Gateway | 4001 | 4002 |
These are only defaults. You can change them in Global Configuration → API → Settings, and the port in your code must match. Docker images often map different ports, so check the documentation for the image you use.
Two settings catch people out:
API settings are saved separately for the live and paper users. Enabling “Enable ActiveX and Socket Clients” on your live login does nothing for your paper login. You must configure each one.
TWS starts in Read-Only API mode. The Read-Only setting is on by default and blocks all API orders. Turn it off for the paper user before testing order placement.
Example: connect to IBKR paper trading with ib_async
This Python example uses ib_async 2.1.0, the maintained successor to ib_insync (see our ib_insync vs ib_async migration guide). It connects to IB Gateway in paper mode, refuses to run if the session isn’t the paper account you expect, places a small limit order well away from the market, and cancels it.
import asyncio
import os
from ib_async import IB, LimitOrder, Stock
HOST = "127.0.0.1"
PAPER_PORT = 4002 # IB Gateway paper default (TWS paper: 7497)
PAPER_ACCOUNT = os.environ["IBKR_PAPER_ACCOUNT"] # your paper account number
async def main():
ib = IB()
await ib.connectAsync(HOST, PAPER_PORT, clientId=11)
# Safety check: stop if this session isn't the paper account we expect.
accounts = ib.managedAccounts()
if PAPER_ACCOUNT not in accounts:
ib.disconnect()
raise SystemExit(f"Not the expected paper account: {accounts}")
# Without shared live data, the paper user gets delayed data.
ib.reqMarketDataType(3) # 3 = Delayed
contract = Stock("AAPL", "SMART", "USD")
await ib.qualifyContractsAsync(contract)
# A buy limit far below the market, so it should rest and not fill.
order = LimitOrder("BUY", 1, 1.00, account=PAPER_ACCOUNT, tif="DAY")
trade = ib.placeOrder(contract, order)
await asyncio.sleep(2)
print("Status after placing:", trade.orderStatus.status)
ib.cancelOrder(order)
await asyncio.sleep(2)
print("Status after cancel:", trade.orderStatus.status)
ib.disconnect()
asyncio.run(main())Some notes on the example:
Checking the account ID before sending anything is the cheapest protection against a live session on the wrong port. In IBKR’s own examples, paper account IDs start with “DU”, but check against your exact paper account number rather than a prefix.
Market data type 3 asks for delayed data. IBKR returns the best data your subscriptions allow regardless of the type you request, so the same code works when live data is shared.
Each API connection needs a unique client ID. Reusing one gives error 326 (“Unable to connect as the client id is already in use”).
How IBKR paper trading differs from live trading
IBKR is open about the simulator’s limits. Its paper trading FAQ lists these differences:
Area | What changes in paper trading |
Execution | Trades aren’t sent to real markets. IBKR simulates the role of the exchange, so fill prices and speed can differ. |
Market impact | Your orders don’t move prices, and you may get more favorable fills than in live trading. |
Order book | Fills are simulated from the top of the book only, with no deep book. |
Order types | Some aren’t supported, including Passive Relative, Auction, RFQ, Pegged to Market and Market with Protection for CME futures. Stops and complex orders behave differently. |
Combos and options | Combo trading is limited, there is no penny trading in US options, and option exercise and expiration processing differs. |
Market orders | Partially executed exchange-directed market orders may have the remainder rejected. |
Products and tools | No mutual fund trading, and only limited Client Portal functions. |
Configuration | Default settings may restrict orders to regular trading hours (RTH). |
IBKR’s own summary is that paper accounts are designed for education and strategy testing, not for an exact copy of live trading conditions. In practice, that means paper P&L is optimistic. It shows that your logic works, not that your edge survives real fills.
Market data in a paper account
The paper user doesn’t have market data subscriptions of its own. IBKR lets you set it up in one of two ways:
Share the live user’s subscriptions. The paper session gets live data, but only if the live and paper sessions run on the same device. If the live user is logged in somewhere else at the same time, the paper session gets no data.
Don’t share. The two sessions are independent and can run anywhere, and the paper user receives delayed data.
This matters for servers. If your paper IB Gateway runs in the cloud while you’re logged in to the live account on your laptop with sharing on, the paper Gateway gets no data. In the API this shows up as error 10197 (“No market data during competing session”). IBKR also notes that a paper session sharing data with a live user won’t receive market data while that live user is logged in to Client Portal. The fix IBKR suggests is a second live username for your account, which has its own market data fees.
Remember too that the API counts as off-platform use. IBKR says most instruments need a Level 1 market data subscription for real-time data through the API, even when TWS shows free data on screen.
A testing strategy before going live
Here is the order we follow on IBKR projects, including the multi-account desk described in our IBKR options trading automation case study.
Connectivity. Connect, check the account ID, request contract details and market data, and log every error code you receive.
Order lifecycle. Place, modify and cancel each order type you plan to use. Confirm status changes, executions and commissions reach your database.
Failure handling. Kill the Gateway, block the network, restart your app mid-order. After every reconnect, your app should reconcile open orders and positions with IBKR before doing anything else.
Scheduled events. Let the system run through the daily restart and a weekend in paper. That is the cheapest way to find out how your app behaves when the session drops.
Multi-account logic. If you allocate orders across accounts, verify the per-account quantities in code. Our IBKR FA allocation guide covers the methods. Check which accounts your paper login actually reports before testing allocation, because IBKR’s public docs don’t spell out how a paper advisor login mirrors client accounts.
Small live run. Move to live with minimum size and the same monitoring. Compare live fills against paper fills for the same signals. That gap is the part paper trading can’t show you.
Common IBKR paper trading pitfalls
Connecting to live by accident. Port 7496 and port 7497 differ by one digit. Keep ports in configuration, not in code, and assert the account ID at startup.
Forgetting the paper user’s API settings. If the connection is refused, check that socket clients are enabled for the paper user and the port matches. Error 502 points to exactly this.
Orders rejected for no clear reason. Check Read-Only API mode, whether the order type is supported in paper, and whether the order falls outside regular trading hours.
No or delayed data on a server. Check market data sharing and whether the live user is logged in on another device.
Trusting paper fills. Top-of-book fills with no market impact flatter any strategy that trades size, uses market orders or trades thin options.
Treating the paper account as permanent state. Balance resets replace your test data. Keep your own records of test runs.
FAQ
Do I need a funded account for IBKR paper trading?
Yes. IBKR’s FAQ says the paper trading account is only accessible once your live account has been funded. Market data is the other thing to plan for: the paper user shares the live user’s subscriptions or receives delayed data, and a second live user for simultaneous sessions has its own market data fees.
How do I get an Interactive Brokers paper trading account?
Fund your live IBKR account, then log in to Client Portal and go to Settings, Account Configuration, Paper Trading Account. There you can see the paper username and reset its password. Use those credentials to log in to paper trading in TWS, IB Gateway, Client Portal or IBKR Mobile.
Can I use the IBKR API with a paper account?
Yes. Both the TWS API and the Web API work with paper accounts. For the TWS API, log TWS or IB Gateway into the paper account and connect to its socket port. For the Web API, log in to the Client Portal Gateway with your paper username.
What port does IBKR paper trading use?
By default, TWS listens on port 7497 for paper trading and 7496 for live. IB Gateway uses 4002 for paper and 4001 for live. These are defaults you can change in Global Configuration → API → Settings, and Docker images may map different ports.
Why is there no market data in my paper account?
The paper user has no subscriptions of its own. If it shares the live user’s data and the live user is logged in on another device, the paper session gets no data. If sharing is off, it gets delayed data. Through the API, most instruments also need a Level 1 subscription for real-time data.
How do I reset my IBKR paper trading balance?
Log in to the paper Client Portal, open Account Settings and click the gear icon next to Paper Trading Account Reset. You can choose an amount up to five times your production account value. Requests entered before 16:00 EST take effect the next business day.
Are paper trading results the same as live trading?
No. IBKR simulates the exchange, fills come from the top of the book, your orders have no market impact, and some order types aren’t supported. Paper results are usually better than live, so use paper to test code and workflows, then confirm behavior with a small live run.





