IBAPI Error 354: Requested Market Data Is Not Subscribed
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.
- 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.
| Code | Message | Data arrives? | Fix |
|---|---|---|---|
| 354 | Requested market data is not subscribed | No | Buy the real-time subscription for that exchange, or call reqMarketDataType(3) and retry |
| 10167 | Requested market data is not subscribed. Displaying delayed market data | Yes, delayed (about 15 min) | Nothing required; handle tick types 66 to 75 |
| 10168 | Requested market data is not subscribed. Delayed market data is not enabled | No | Call reqMarketDataType(3) after connect and before reqMktData |
| 10090 | Part of requested market data is not subscribed | Partial | Remove generic ticks you do not need, or subscribe to the missing component |
| 10197 | No market data during competing live session | No | Log out of the other session using the same username (live or TWS elsewhere) |
| 162 | Historical Market Data Service error message (for example no market data permissions) | No bars | Check the subscription, whatToShow and contract; see the historical section |
| 101 | Max number of tickers has been reached | Existing lines only | Cancel unused lines with cancelMktData; default is 100 lines |
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:
| Value | Mode | Behaviour |
|---|---|---|
| 1 | Live | Real-time; requires a subscription |
| 2 | Frozen | Last available quote, useful when the market is closed |
| 3 | Delayed | About 15 minutes late, free for many US exchanges |
| 4 | Delayed-frozen | Delayed data, frozen snapshot after close |
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()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:
- Confirm the live account is funded, and that its market data agreements are signed and the subscription is active.
- In Account Management open Settings, then Paper Trading Account, and enable 'Share real-time market data subscriptions with paper trading account'.
- Allow time for the change to apply, then restart TWS or Gateway.
- 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.
- Connect to the paper port (7497 for TWS, 4002 for Gateway) and test AAPL on SMART in USD.
- Expect paper data to differ slightly from live, for example in size and fill behaviour.
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:
| Symptom | Likely cause | Fix |
|---|---|---|
| No ticks, no error | Market closed, or no thread running | Use type 2 or 4; verify app.run thread is alive |
| Error 200 or no security definition | Wrong secType, exchange, currency or primaryExchange | Specify SMART with primaryExchange for ambiguous symbols |
| Futures return nothing | Expired or missing lastTradeDateOrContractMonth | Use a current expiry such as 202703 |
| 10090 with generic ticks | Generic tick list not supported for the product | Pass '' as genericTickList |
| Error 101 | More than 100 lines open | Call cancelMktData for unused ids |
| Error 162 on reqHistoricalData | No historical permission for that whatToShow, or a pacing violation | Try 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:
- Log every error() code and message; do not filter them.
- Request AAPL, SMART, USD with reqMarketDataType(3). If delayed ticks arrive, your code path works and the issue is entitlement or contract.
- Check the TWS market data lines, and cancel unused subscriptions to stay below the line limit.
- For paper accounts, verify sharing and that no other session uses the live username (10197).
- Fix the contract fields for your real instrument, then try type 2 or 4 if the market is closed.
- 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.