Howwise RSS
Trading Software8 min read

IBKR Error 10197 Market Data: Causes and Fixes (354, 10167)

Short answer

IBKR error 10197 market data means the same username has a competing live session on another TWS, Gateway, Client Portal or mobile login. Close it or use a separate data username. Errors 354 and 10167 are subscription issues.

Key takeaways
  • Error 10197 means a competing live session holds the username's market data, while 354 means no subscription for that instrument or exchange.
  • Error 10167 is not a failure: delayed data is flowing, but only through delayed tick IDs (66, 67, 68, 75) that live-only handlers ignore.
  • Call reqMarketDataType before reqMktData; type 3 gives delayed data as a fallback, and it must be set before the request.
  • A paper account only sees live data if sharing is enabled in Account Management and the primary holder's live account owns the subscriptions.
  • Classify errors per reqId in code and log which tick types and marketDataType actually arrive, which tells you the root cause in seconds.

What does IBKR error 10197 market data mean, and how do 354, 10167 and 10090 differ?

Almost every missing-data case falls into one of three root causes: you are not subscribed, another session is holding the data, or you are receiving delayed data that your code does not read. The error code tells you which one. Prices of -1, NaN or no ticks at all are the symptoms, not the diagnosis.

Error 10197 (No market data during competing live session) is the one that surprises people. IBKR allows one live market data session per username, so a login elsewhere takes the data away from the API session.

CodeMessage meaningRoot causeFirst action
354Requested market data is not subscribedNo subscription for that instrument or exchangeSubscribe, or request delayed data with type 3
10197No market data during competing live sessionSame username live in another TWS, Gateway, Client Portal or mobile appClose the other session or use a second username
10167Requested market data is not subscribed, displaying delayed dataDelayed fallback is activeRead delayed tick IDs, or subscribe for live
10090Part of requested market data is not subscribedSome fields are entitled and some are notCheck which tick types arrive and which are missing
10089Requires additional subscription for APIData shown in TWS needs a separate API entitlementCheck the subscription is enabled for API use
101Max number of tickers reachedMarket data lines exhaustedCancel unused streams or use snapshots

Why does IBKR error 10197 market data appear when I run a script?

The data entitlement belongs to the username, not to the client ID. Running a script with a different clientId does not help, because TWS on a laptop, a phone app or a Client Portal tab on the same login is a competing session.

The usual triggers are TWS left open on another machine, the IBKR Mobile app launched in the background, or a Gateway that auto-restarted while you were logged in elsewhere. The other session may be one you forgot about, so check every device first.

  1. Log out of every other TWS, IB Gateway, Client Portal and mobile session on that username. Closing the window is not enough for a phone app, so sign out inside it.
  2. Restart the API connection and re-issue the reqMktData call, because a stream that was interrupted by the competing session does not reliably resume on its own.
  3. If you need both a GUI and an API at once, create a second username under Account Management so each program has its own login and its own live data session.
  4. Check how the second username is entitled. Subscriptions are held by the account, but confirm in Account Management that the new username can see them, and test with SPY before relying on it.
  5. Do not share one username's credentials between a trading GUI and a production bot. Each new login can silently pull live data away from the other.
Tip: Orders and account data still work during a competing session. Only market data is blocked, so a script can trade fine and still show empty prices.

How do I get delayed data with reqMarketDataType 3?

reqMarketDataType sets the data mode for all later reqMktData calls on that connection. The values are 1 live, 2 frozen, 3 delayed and 4 delayed-frozen.

Type 3 asks for live data when you are entitled and falls back to delayed (typically about 15 minutes behind) when you are not. That fallback is what produces the 10167 message, and no extra fee applies for the API. Type 4 behaves like 3 but also returns the last available values when the market is closed.

Frozen (2) returns the last recorded bid/ask/last for closed markets and needs a live entitlement. Order matters: call it after connecting and before reqMktData, otherwise the request is already running in the old mode.

TypeNameNeeds subscriptionTypical use
1LiveYesDefault, streaming
2FrozenYesLast values after close
3DelayedNo (falls back)Development and testing without data fees
4Delayed-frozenNoDelayed plus closed-market values

Why are my delayed ticks empty even though data arrives?

Delayed values come through different tick IDs, so a handler that only checks live IDs sees nothing. In ibapi tickPrice, delayed bid is 66, delayed ask 67, delayed last 68, delayed close 75 and delayed open 76. Sizes are 69, 70 and 71, delayed volume is 74, and 88 is the delayed last timestamp.

Live IDs are 1 bid, 2 ask, 4 last, 9 close. A handler written as `if tickType == 4` will silently drop every delayed trade price.

ib_insync keeps the two sets apart. ticker.last holds live trades only, because it is filled from live tick 4. Delayed values must be read from ticker.delayedBid, ticker.delayedAsk, ticker.delayedLast and ticker.delayedClose. Check ticker.marketDataType to see which mode you are in.

# ibapi: handle live and delayed tick types together
LIVE_TO_NAME = {1: 'bid', 2: 'ask', 4: 'last', 9: 'close'}
DELAYED_TO_NAME = {66: 'bid', 67: 'ask', 68: 'last', 75: 'close', 76: 'open'}

def tickPrice(self, reqId, tickType, price, attrib):
    name = LIVE_TO_NAME.get(tickType) or DELAYED_TO_NAME.get(tickType)
    delayed = tickType in DELAYED_TO_NAME
    if name and price > 0:          # -1 means no value
        print(reqId, name, price, 'DELAYED' if delayed else 'LIVE')

def marketDataType(self, reqId, marketDataType):
    print('reqId', reqId, 'data type now', marketDataType)

Working error classifier for ibapi and ib_insync

The script below sets the data type first, requests SPY, classifies the error codes per reqId and prints a suggested action. Request IDs matter because a 354 on one contract does not mean the whole session is unentitled. Note that ib_insync is no longer actively maintained, and the ib_async fork keeps the same API.

Run it against a paper or live session with a small symbol list. If SPY works and your target does not, the problem is that instrument's exchange bundle, not the session.

ACTIONS = {
    354:   'Not subscribed: subscribe to the exchange bundle or use reqMarketDataType(3)',
    10197: 'Competing live session: close other TWS/Gateway/Mobile/Client Portal on this username',
    10167: 'Delayed data is being delivered: read tick IDs 66/67/68/75 or subscribe for live',
    10090: 'Partial data: some fields not entitled, check which tick types arrive',
    10089: 'Needs additional API subscription for this data',
    101:   'Market data line limit reached: cancel streams or use snapshots',
    162:   'Historical data service error: check entitlement, whatToShow and useRTH',
    366:   'No historical data query found for this ticker id',
}

# ---- ib_insync / ib_async ----
from ib_insync import IB, Stock
import time

ib = IB()
ib.connect('127.0.0.1', 7497, clientId=11)   # 7497 TWS paper, 4002 Gateway paper
ib.reqMarketDataType(3)                       # BEFORE reqMktData

def on_error(reqId, code, msg, contract):
    print(f'[{reqId}] {code} {msg} -> {ACTIONS.get(code, "see message")}')
ib.errorEvent += on_error

contract = Stock('SPY', 'SMART', 'USD')
ib.qualifyContracts(contract)                 # resolves conId and primaryExchange
ticker = ib.reqMktData(contract, genericTickList='', snapshot=False)
ib.sleep(4)
print('marketDataType:', ticker.marketDataType)   # 1 live, 3 delayed
print('bid/ask/last:', ticker.bid, ticker.ask, ticker.last)
print('delayed:', ticker.delayedBid, ticker.delayedAsk, ticker.delayedLast)
ib.cancelMktData(contract)
ib.disconnect()

# ---- ibapi: error callback ----
# def error(self, reqId, errorCode, errorString, advancedOrderRejectJson=''):
#     print(reqId, errorCode, errorString, '->', ACTIONS.get(errorCode, ''))
# app.reqMarketDataType(3)
# app.reqMktData(1001, contract, '', False, False, [])
Warning: Informational codes such as 2104, 2106 and 2158 (data farm connection messages) are not errors. Do not treat them as failures when classifying.

Does a paper account share market data, and what subscriptions do I need?

A paper account has no market data of its own. It can share the live account's subscriptions only when sharing is enabled in Account Management (Paper Trading Account settings). The live account must hold the subscriptions, and the data is read-only on the paper side. Sharing works from the primary account holder's live username, so a secondary username will not carry it.

Without sharing, expect 354 or delayed data on paper. Separately, the paper login can itself be a competing session: if you log into the live account and the paper account together with sharing on, 10197 can appear depending on which session holds the data.

Subscriptions are bought per exchange bundle, for example US Securities Snapshot and Futures Value Bundle or NASDAQ (Network C/UTP). The following apply:

RequirementDetail
Funded live accountSubscriptions need a funded live account, and a funding minimum may apply
Non-professional statusThe non-professional declaration must be signed, or professional rates and rules apply
API feeThe API itself is free, but the data is not
Per-exchange bundlesA bundle covers specific exchanges only; other exchanges still give 354
Crypto and some bondsNeed their own separate subscriptions
PropagationAfter a change, restart TWS or Gateway and allow a few minutes

Snapshots, line limits, historical data and a diagnostic checklist

Snapshots (the snapshot flag set to true in reqMktData) return one set of values and then end. They can incur per-snapshot fees for exchanges you are not subscribed to, and they cannot be combined with a genericTickList. Streaming uses market data lines: the default is 100, scaling with commissions and equity, and exceeding it returns error 101.

Historical data entitlements differ from real-time. reqHistoricalData often works with delayed access, but a missing entitlement returns 162, and 366 means no query with that ticker id exists, typically after a cancel or a duplicate id. Set whatToShow to TRADES, MIDPOINT, BID or ASK deliberately, since some instruments only offer some of them, and set useRTH to 1 to limit bars to regular trading hours.

Run through this checklist when data is still missing:

  1. Confirm the same symbol shows a price in TWS desktop under the same login. If it does not, the issue is the subscription, not your code.
  2. Qualify the contract: secType, currency and exchange. Use SMART for routing, and set primaryExchange (ISLAND for NASDAQ names) if the symbol is ambiguous.
  3. Call reqMarketDataType before reqMktData, never after.
  4. Log every error per reqId and print marketDataType and the tick types received.
  5. Check for another session on the same username, including mobile.
  6. Restart after any subscription change and wait a few minutes.
Tip: A common mistake is testing a thinly traded instrument and concluding the API is broken. Test with SPY first to separate entitlement problems from contract problems.

Common questions

What is the difference between error 354 and error 10167?

Error 354 means no data was delivered because you are not subscribed. Error 10167 carries the same not-subscribed message but adds that delayed data is being displayed, so ticks do arrive, just on delayed tick IDs.

Why do I get -1 or NaN prices from reqMktData?

A price of -1 is the API placeholder for no value, which happens during 354 or 10197, outside trading hours, or when the field is not entitled. In ib_insync the fields stay NaN until a tick arrives, so check the error handler and ticker.marketDataType before debugging your code.

Can I use a second username to run the API next to TWS?

Yes. A second username under the same account lets the API and TWS run at once without 10197, because each login has its own data session. Confirm in Account Management that the new username can see your subscriptions, otherwise it receives only delayed data or 354.

Will delayed data work on a paper account without a subscription?

Yes, in most cases. Call reqMarketDataType(3) before requesting and read the delayed tick IDs (66, 67, 68, 75). Live data on paper requires enabled sharing from the primary holder's live account.

How long do new market data subscriptions take to work in the API?

Usually a few minutes, but sessions already open may not pick them up. Restart TWS or IB Gateway, reconnect your script and re-request the data, since a stream that started before the change keeps the old entitlement.

Related topics:ibkrtws apimarket dataibinsyncerror codes