Howwise RSS
Trading Software9 min read

ibapi error 10089: Causes, Fixes and Error Handling

Short answer

ibapi error 10089 means the API request needs a market data subscription that the API session cannot use yet, usually a missing Market Data API Acknowledgement. Delayed data is still available through reqMarketDataType(3).

Key takeaways
  • 10089 means the API is refused data that may still display in TWS, while 354 means no subscription exists at all.
  • Sign the Market Data API Acknowledgement in Account Management, then restart TWS or Gateway so the change takes effect.
  • Call reqMarketDataType(3) before reqMktData to get delayed data, and read tick types 66, 67 and 68 instead of 1, 2 and 4.
  • 10197 is a session conflict, not a billing problem, so give the API its own username.
  • Codes 2104, 2106 and 2158 are farm status messages, so never treat them as failures or retry on them.

What does ibapi error 10089 actually mean?

The full text is "Requested market data requires additional subscription for API. See link in 'Market Data Connections' section. Delayed market data is available." The server found a subscription path for the instrument, but the API connection is not entitled to use it.

The usual causes are an unsigned Market Data API Acknowledgement, a subscription bundle that is display-only for TWS, or a professional/non-professional status mismatch. The "delayed available" tail tells you a fallback exists.

The error arrives through EWrapper.error with the reqId of your reqMktData call. No ticks follow it on that request, so a script that only waits for tickPrice will hang silently.

Which error do I have? 10089, 354, 10167, 10197 or 162

Read the code first, not the text of the message. Each code points at a different layer, and the fix for one makes no difference to another.

Informational codes 2104, 2106 and 2158 report that the market data, historical data and security definition farms are connected. They are not errors.

CodeMessage gistLayerTypical fix
10089Needs additional subscription for API; delayed availableAccount / API entitlementSign API acknowledgement, restart, or use delayed type 3
354Requested market data is not subscribedAccount: no subscriptionSubscribe to the right exchange bundle, or use delayed type 3
10167Not subscribed, displaying delayed dataAccount, but data flowsHandle delayed ticks 66-68, or subscribe
10197No market data during competing live sessionSessionClose the other login or use a separate API username
162Historical data service errorHistorical farmRead the text: pacing, permissions, or bad request
200No security definition foundContractFix symbol, exchange, secType, currency
101Max number of tickers reachedLine limitCancel unused streams or buy more lines
2104/2106/2158Farm connection OKInformationalLog at debug level and ignore
Tip: 354 and 10197 each have their own deep-dive pages on this site. This page covers how to tell them apart and handle them in code.

What is the difference between 10089 and 354?

354 means the account has no entitlement for that instrument's exchange at all. TWS would show nothing either, or would show delayed quotes if delayed data is enabled in the client.

10089 means TWS may display the quote, but the API is not allowed the same feed. Market data for API use requires its own acknowledgement and, for some bundles, a status that supports API use. That is why the same watchlist row can work in TWS while reqMktData fails.

10167 sits between them. The request is unsubscribed, but the server is sending delayed ticks, so you receive data and an error together. Treat it as a warning and switch your tick handling to the delayed types.

The 162 code is separate and arrives only on reqHistoricalData. Its text decides the cause. A message mentioning pacing or "HMDS query returned no data" is a request or rate problem. A message about permissions or "market data is not subscribed" is an entitlement problem.

How do I fix the subscription and account setup?

Do the account steps in this order, because the API acknowledgement is only offered once a subscription exists. Market data subscriptions generally need a funded account, and the minimum equity rule depends on the account type, so confirm it in Account Management.

Changes do not apply to a running session. Restart TWS or IB Gateway after each change, and do not just reconnect the API.

  1. Log in to Account Management and open Settings, then Market Data Subscriptions.
  2. Set your status correctly as non-professional or professional. Professional status changes both the price and the available bundles, and it must be accurate.
  3. Subscribe to the bundle that covers the exchange of your contract, for example a US equity bundle for NYSE, Nasdaq and AMEX symbols.
  4. Sign the Market Data API Acknowledgement, which appears in the same area once you hold a subscription.
  5. Fully close and restart TWS or IB Gateway so the new entitlements are loaded.
  6. Check the quote in a TWS watchlist for the same contract. If it shows there but the API still returns 10089, the acknowledgement or a session conflict is the cause.
Warning: Subscriptions cost money monthly, and professional status carries much higher fees. Do not subscribe just to test code. Delayed data is free and enough to validate the code path.

How do I use reqMarketDataType to get delayed data?

reqMarketDataType sets the data class for all later reqMktData calls on that connection. Call it before reqMktData, and call it again after any reconnect because the setting is not persistent.

The values are 1 for live, 2 for frozen (last available data after the close), 3 for delayed, and 4 for delayed-frozen. Delayed data is typically about 15 minutes behind. Delayed-frozen combines both behaviors when the market is closed.

The server confirms the active mode through the marketDataType(reqId, marketDataType) callback. Use that callback to see which mode you actually received.

Delayed data arrives on different tick types. Delayed bid, ask and last are tick types 66, 67 and 68, where live uses 1, 2 and 4. Delayed bid size, ask size and last size are 69, 70 and 71. If your tickPrice handler filters only on 1, 2 and 4, a delayed session looks empty even though data is flowing.

FieldLive tick typeDelayed tick type
Bid price166
Ask price267
Last price468
Bid size069
Ask size370
Last size571

How do I capture these errors and fall back in code?

The error callback signature has changed between versions. Older releases use error(reqId, errorCode, errorString), then advancedOrderRejectJson was added, and recent releases also add an errorTime argument. Accept *args and parse from the end so one wrapper survives upgrades.

Route every error by reqId. Errors with reqId -1 are connection-wide, such as farm status or lost connectivity, and must not be attributed to one request. Classify first and retry only on the one case that has a safe fallback, which is a subscription error answered by delayed data.

The sketch below switches to delayed data once per request on 10089, 354 or 10168, and fails clearly on session and contract errors. It also adds a timeout, because a request that raises no error and delivers no tick is a real failure mode.

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

INFO = {2104, 2106, 2107, 2108, 2158}
SUBSCRIPTION = {10089, 354, 10167, 10168}
SESSION = {10197}
CONTRACT = {200, 321}
LIMIT = {101}

def classify(code, msg=""):
    if code in INFO: return "info"
    if code in SUBSCRIPTION: return "subscription"
    if code in SESSION: return "session"
    if code in CONTRACT: return "contract"
    if code in LIMIT: return "limit"
    if code == 162:
        m = msg.lower()
        return "pacing" if "pacing" in m else ("subscription" if "subscri" in m or "permission" in m else "history")
    return "other"

class App(EWrapper, EClient):
    def __init__(self):
        EClient.__init__(self, self)
        self.reqs = {}      # reqId -> contract
        self.retried = set()
        self.ticks = {}     # reqId -> {tickType: price}
        self.failed = {}    # reqId -> (code, kind, msg)

    def error(self, reqId, *args):
        # handles (code, msg), (code, msg, json) and (time, code, msg, json)
        args = list(args)
        if len(args) >= 3 and isinstance(args[0], int) and args[0] > 10**9:
            args = args[1:]  # drop errorTime
        code, msg = args[0], args[1]
        kind = classify(code, msg)
        logging.log(logging.DEBUG if kind == "info" else logging.WARNING,
                    "reqId=%s code=%s kind=%s %s", reqId, code, kind, msg)
        if kind == "info" or reqId == -1:
            return
        if kind == "subscription" and reqId in self.reqs and reqId not in self.retried:
            self.retried.add(reqId)
            self.cancelMktData(reqId)
            self.reqMarketDataType(3)
            self.reqMktData(reqId, self.reqs[reqId], "", False, False, [])
            return
        self.failed[reqId] = (code, kind, msg)

    def marketDataType(self, reqId, mdt):
        logging.info("reqId=%s data type now %s", reqId, mdt)

    def tickPrice(self, reqId, tickType, price, attrib):
        if tickType in (1, 2, 4, 66, 67, 68) and price > 0:
            self.ticks.setdefault(reqId, {})[tickType] = price

def wait_for_tick(app, reqId, timeout=10):
    end = time.time() + timeout
    while time.time() < end:
        if reqId in app.ticks: return app.ticks[reqId]
        if reqId in app.failed: raise RuntimeError(app.failed[reqId])
        time.sleep(0.1)
    raise TimeoutError(f"no tick for reqId {reqId} in {timeout}s")

app = App()
app.connect("127.0.0.1", 7497, clientId=7)
threading.Thread(target=app.run, daemon=True).start()
time.sleep(1)
c = Contract()
c.symbol, c.secType, c.exchange, c.currency = "AAPL", "STK", "SMART", "USD"
c.primaryExchange = "NASDAQ"
app.reqs[1] = c
app.reqMarketDataType(1)
app.reqMktData(1, c, "", False, False, [])
print(wait_for_tick(app, 1))
Warning: Never loop retries on 10197, 200 or 162 pacing. Retrying a session conflict does nothing, and retrying a pacing violation extends the penalty. Add a backoff of several seconds for history requests.

Why do paper accounts, concurrent sessions and contracts mimic these errors?

Paper accounts do not hold their own subscriptions. They can mirror the live account's subscriptions only if sharing is enabled in Account Management, and generally only while the live username is not logged in at the same moment. Use the separate paper username for API work, and set delayed data in the paper session if sharing is off.

10197 comes from the one-live-session rule. Each username can stream market data in only one place. TWS, the mobile app, Client Portal or a second Gateway logging in with the same username takes the session, and the API loses its data. Create a second username for API use, with its own subscription if needed.

Gateway's daily auto-restart and relogin can also change which session holds the data. After a restart, resubmit reqMarketDataType and your subscriptions, since the old request IDs are gone.

A wrong contract mimics subscription errors. SMART with a primaryExchange set to the listing exchange is the safe form for US stocks. Asking for ISLAND directly can need a different entitlement than SMART. Call reqContractDetails first. A 200 error there means the contract is wrong, and no subscription would fix it.

SymptomLikely causeCheck
TWS has quotes, API gives 10089API acknowledgement missingAccount Management, API acknowledgement, then restart
API worked, then 10197 mid-dayAnother login stole the sessionClose mobile, TWS or Client Portal, or use a separate username
Paper gives 354, live worksSharing off or live user logged inEnable sharing, or use delayed type 3
200 on requestWrong symbol, secType or exchangereqContractDetails with fewer fields

How do historical requests, snapshots and line limits fit in?

reqHistoricalData does not need reqMarketDataType(3) in many cases, because historical data often comes from a separate farm with its own rules. Entitlement still matters for exchange-specific products, and a 162 whose text mentions subscriptions is a permissions issue.

whatToShow changes what you receive and what you need. TRADES is the common case for stocks. MIDPOINT and BID_ASK use quote data and suit instruments with sparse trades. Set useRTH to 1 to restrict output to regular trading hours, which also reduces empty-result puzzles outside the session.

A snapshot, with snapshot=True in reqMktData, returns one set of values and then ends. It may carry a per-request fee for subscribed exchanges, and you cannot combine it with a generic tick list. Streaming uses a market data line. The default allotment is 100 simultaneous lines, and exceeding it returns error 101, so cancel finished requests with cancelMktData.

Generic tick lists, such as "233" for RT Volume, ask for extra fields on a streaming request. They do not substitute for a subscription, and an invalid list can produce its own error.

Common questions

Is ibapi error 10089 a code bug or an account problem?

It is almost always an account or entitlement problem rather than a code bug. The request itself is valid, but the API session is not allowed that feed. Sign the Market Data API Acknowledgement, restart TWS or Gateway, and use reqMarketDataType(3) while you wait.

Do I need to pay to remove error 10089?

Not necessarily. Delayed data is available without a live subscription, so reqMarketDataType(3) with delayed ticks 66 to 68 can serve development and non-time-sensitive jobs. You need a paid subscription and the API acknowledgement only for live data.

Why does ib_insync show 10089 but TWS shows quotes?

ib_insync uses the same API path as ibapi, so it hits the same entitlement check. TWS display can work from a subscription that the API acknowledgement does not cover. Use ib.reqMarketDataType(3) before ib.reqMktData, and watch ib.errorEvent for the code.

Are errors 2104, 2106 and 2158 a problem?

No. They report that the market data, historical data and security definition farms are connected or inactive-but-ready. Log them at debug level and exclude them from any failure or retry logic.

Why do I get no ticks and no error at all?

Common causes are a closed market with live type 1 and no frozen fallback, a filter that ignores delayed tick types, or a request that was silently dropped after a disconnect. Use reqMarketDataType(2) or 4 outside trading hours, and add a timeout so the script fails with a clear message.

Related topics:ibapiinteractive brokersmarket datatws apierror handling