Howwise RSS
Trading Software6 min read

IBAPI Error 354: Requested Market Data Is Not Subscribed

Short answer

IBAPI error 354 'Requested market data is not subscribed' means no data will arrive for that request. Fix it by buying the real-time subscription, or call reqMarketDataType(3) before reqMktData to receive delayed ticks.

Key takeaways
  • Error 10167 is a warning: delayed ticks are arriving, but under tick types 66 to 75 rather than 1, 2 and 4.
  • Errors 354 and 10168 mean no data arrives; 10168 is fixed by calling reqMarketDataType(3) before reqMktData.
  • Paper accounts share the live username's subscriptions, and 10197 appears when the live session is logged in elsewhere.
  • Handle these codes by number in the error() callback instead of treating every error as fatal.
  • Seeing quotes in TWS does not prove the API has the same entitlement; test with AAPL on SMART/USD.

What does ibapi error 354 mean, and how do 10167, 10168 and 10090 differ?

IBAPI error 354 and its related codes are mostly informational messages sent through the error callback, not Python exceptions. The same request can produce a warning with working data (10167) or a hard failure with no data (354, 10168), so read the code before acting.

The decision table below maps each code to what you have and what to do.

CodeMessageData arrives?Fix
354Requested market data is not subscribedNoBuy the real-time subscription for that exchange, or call reqMarketDataType(3) and retry
10167Requested market data is not subscribed. Displaying delayed market dataYes, delayed (about 15 min)Nothing required; handle tick types 66 to 75
10168Requested market data is not subscribed. Delayed market data is not enabledNoCall reqMarketDataType(3) after connect and before reqMktData
10090Part of requested market data is not subscribedPartialRemove generic ticks you do not need, or subscribe to the missing component
10197No market data during competing live sessionNoLog out of the other session using the same username (live or TWS elsewhere)
162Historical Market Data Service error message (for example no market data permissions)No barsCheck the subscription, whatToShow and contract; see the historical section
101Max number of tickers has been reachedExisting lines onlyCancel unused lines with cancelMktData; default is 100 lines
Warning: Subscription fees, professional versus non-professional status and signed market data agreements are account decisions made in Account Management. Code cannot change them.

How do I get delayed data with reqMarketDataType(3)?

reqMarketDataType switches what the session returns for later requests. It must run after the connection is ready and before reqMktData, otherwise the first request has already been rejected under the live setting.

The values are:

ValueModeBehaviour
1LiveReal-time; requires a subscription
2FrozenLast available quote, useful when the market is closed
3DelayedAbout 15 minutes late, free for many US exchanges
4Delayed-frozenDelayed data, frozen snapshot after close
Tip: If you request type 1 and have no subscription you get 354 or 10168. If you request type 3 and have no subscription you get 10167 and delayed ticks.

What is a minimal ibapi script that prints live and delayed ticks?

The script below connects, waits for nextValidId, sets delayed mode, requests AAPL and prints the tick type by name. A thread runs the message loop; without it, nothing is processed.

Delayed ticks arrive as types 66 to 75, so a handler that only checks types 1, 2 and 4 prints nothing.

import threading, time
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract

NAMES = {1:'BID',2:'ASK',4:'LAST',6:'HIGH',7:'LOW',9:'CLOSE',14:'OPEN',
 66:'DELAYED_BID',67:'DELAYED_ASK',68:'DELAYED_LAST',
 69:'DELAYED_BID_SIZE',70:'DELAYED_ASK_SIZE',71:'DELAYED_LAST_SIZE',
 72:'DELAYED_HIGH',73:'DELAYED_LOW',74:'DELAYED_CLOSE',75:'DELAYED_OPEN'}
INFO = {10167, 10090, 2104, 2106, 2158, 2119}

class App(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self, self)
        self.ready = threading.Event()

    def nextValidId(self, orderId):
        self.next_id = orderId
        self.ready.set()

    # Newer ibapi adds advancedOrderRejectJson; the default keeps both versions working
    def error(self, reqId, errorCode, errorString, advancedOrderRejectJson=''):
        kind = 'INFO' if errorCode in INFO else 'ERROR'
        print(kind, reqId, errorCode, errorString)

    def tickPrice(self, reqId, tickType, price, attrib):
        print('price', reqId, NAMES.get(tickType, tickType), price)

    def tickSize(self, reqId, tickType, size):
        print('size', reqId, NAMES.get(tickType, tickType), size)

app = App()
app.connect('127.0.0.1', 7497, clientId=11)  # 7497 TWS paper, 7496 TWS live, 4002/4001 Gateway
threading.Thread(target=app.run, daemon=True).start()
app.ready.wait(10)

app.reqMarketDataType(3)

c = Contract()
c.symbol, c.secType, c.exchange, c.currency = 'AAPL', 'STK', 'SMART', 'USD'
app.reqMktData(app.next_id, c, '', False, False, [])

time.sleep(15)
app.cancelMktData(app.next_id)
app.disconnect()
Tip: Streaming uses snapshot=False and keeps sending until cancelMktData. Snapshot=True returns one set of values then ends, but may still need entitlement. Give every request a unique reqId, since reusing one overwrites the earlier line.

Why does my paper account show no market data?

A paper account has no subscriptions of its own. It borrows those of the linked live username, and only if sharing is enabled.

Work through this checklist:

  1. Confirm the live account is funded, and that its market data agreements are signed and the subscription is active.
  2. In Account Management open Settings, then Paper Trading Account, and enable 'Share real-time market data subscriptions with paper trading account'.
  3. Allow time for the change to apply, then restart TWS or Gateway.
  4. Make sure the live username is not logged in anywhere else at the same time. Only one real-time session per username is allowed, and a second one triggers 10197.
  5. Connect to the paper port (7497 for TWS, 4002 for Gateway) and test AAPL on SMART in USD.
  6. Expect paper data to differ slightly from live, for example in size and fill behaviour.
Warning: Logging into the live account on a phone app or another machine can silently knock out paper API data with 10197. Close it before debugging code.

Why do I see quotes in TWS but get nothing from the API?

TWS can display delayed quotes by itself, while the API stays on live mode until you call reqMarketDataType(3). That mismatch gives 10168 even though the screen shows prices.

Real-time API data needs the actual subscription, such as an exchange bundle like US Securities Snapshot and Futures Value Bundle, or individual packages like NASDAQ (Network C) and NYSE (Network A). Subscriptions are managed under Settings, Market Data Subscriptions in Client Portal. API use also requires the market data API acknowledgement to be accepted there. The TWS 'enable delayed data' precaution setting is not needed for the API, because reqMarketDataType does the job.

Other causes of silence are worth ruling out:

SymptomLikely causeFix
No ticks, no errorMarket closed, or no thread runningUse type 2 or 4; verify app.run thread is alive
Error 200 or no security definitionWrong secType, exchange, currency or primaryExchangeSpecify SMART with primaryExchange for ambiguous symbols
Futures return nothingExpired or missing lastTradeDateOrContractMonthUse a current expiry such as 202703
10090 with generic ticksGeneric tick list not supported for the productPass '' as genericTickList
Error 101More than 100 lines openCall cancelMktData for unused ids
Error 162 on reqHistoricalDataNo historical permission for that whatToShow, or a pacing violationTry whatToShow='TRADES' versus 'MIDPOINT', and use delayed mode for delayed bars

How do ib_insync and ib_async handle delayed data?

Both libraries wrap the same messages. Call ib.reqMarketDataType(3) right after connect, then request tickers as usual. Delayed fields land in separate attributes such as ticker.delayedBid, ticker.delayedAsk and ticker.delayedLast, so reading ticker.bid will show nan.

from ib_async import IB, Stock  # or: from ib_insync import IB, Stock
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=12)
ib.reqMarketDataType(3)
t = ib.reqMktData(Stock('AAPL', 'SMART', 'USD'), '', False, False)
ib.sleep(5)
print(t.bid, t.delayedBid, t.delayedLast)
ib.cancelMktData(t.contract)
ib.disconnect()

What are the common pitfalls and a final diagnostic order?

Most cases of ibapi error 354 and its relatives come from a few repeated mistakes: calling reqMarketDataType after reqMktData, reusing a reqId, keying callbacks on live tick types only, letting the main thread exit so the run thread dies, and treating 10167 as fatal.

Use this order when data is still missing:

  1. Log every error() code and message; do not filter them.
  2. Request AAPL, SMART, USD with reqMarketDataType(3). If delayed ticks arrive, your code path works and the issue is entitlement or contract.
  3. Check the TWS market data lines, and cancel unused subscriptions to stay below the line limit.
  4. For paper accounts, verify sharing and that no other session uses the live username (10197).
  5. Fix the contract fields for your real instrument, then try type 2 or 4 if the market is closed.
  6. For historical data, test one bar request with a different whatToShow before changing anything else.

Common questions

Is error 10167 a problem I need to fix?

No. It is a warning that you have no real-time subscription and the server is sending delayed data instead. Your handler should accept tick types 66 to 75 and ignore the message.

Does reqMarketDataType(3) work without paying for anything?

For many US exchanges delayed data is available without a subscription, typically about 15 minutes late. Some exchanges and products still need a subscription, so test your exact contract.

Why do I get 10197 on my paper account?

The live username is logged in on another device or session and is holding the single real-time data session. Close that session, then reconnect your API client.

Can I use the delayed data for order logic?

Technically the API delivers it, but it is stale by design, so any logic that assumes current prices will behave differently from live. Treat it as test data for development of the plumbing.

What does 10090 mean when some ticks do arrive?

Part of the request is not covered by your subscriptions, often because a generic tick type is not entitled. Retry with an empty genericTickList to see which fields come through.

Related topics:interactive brokersibapimarket datapythontws api