Registry / finance / ibapi
library9.81.1.post1pypypi✓ verified 83d ago

Official Python client for Interactive Brokers TWS API, version 9.81.1.post1. Provides asynchronous communication with TWS/IB Gateway for order placement, market data, account management. Released on PyPI with monthly cadence, tied to TWS API releases.

pip install ibapi
INSTALL
IMPORT
SIG · IBAPI
I
ibapi
financepythonv9.81.1.post1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EClient
from ibapi.client import EClient
from ib.ext.Contract import Contract
ib.ext is legacy (older than v9.73). All ibapi modules are under ibapi/.
EWrapper
from ibapi.wrapper import EWrapper
from ibapi.wrapper import EWrapper
Correct as is; no common mistake.

Connect to TWS (port 7497 for paper, 7496 for live) and request market data for AAPL.

import time from ibapi.client import EClient from ibapi.wrapper import EWrapper from ibapi.contract import Contract class TestApp(EWrapper, EClient): def __init__(self): EClient.__init__(self, self) def error(self, reqId, errorCode, errorString): print(f'Error: {errorCode} {errorString}') def nextValidId(self, orderId): self.nextOrderId = orderId print(f'Next valid order ID: {orderId}') self.reqMarketDataType(4) # delayed frozen contract = Contract() contract.symbol = 'AAPL' contract.secType = 'STK' contract.exchange = 'SMART' contract.currency = 'USD' self.reqMktData(1, contract, '', False, False, []) def tickPrice(self, reqId, tickType, price, attrib): print(f'TickPrice. reqId: {reqId}, tickType: {tickType}, price: {price}') app = TestApp() app.connect('127.0.0.1', 7497, clientId=1) app.run() time.sleep(2) app.disconnect()
Debug
Known issues
breakingV9.81 removed deprecated methods like reqMktDepthExchanges and reqPositionsMulti. Calls to these result in runtime errors.
fix
Use their replacements: reqMktDepthExchanges is gone; reqPositionsMulti replaced by reqPositions.
affects: >=9.81.0
gotchaThe wrapper callback 'error' changed signature in v9.81: the 'id' parameter is now 'reqId'. Overriding with old signature silently fails.
fix
Ensure your error method has signature: error(self, reqId, errorCode, errorString, advancedOrderRejectJson='')
affects: >=9.81.0
deprecatedUsing integer clientId is deprecated. Future versions may require string IDs.
fix
Consider using string-based clientId in connect() (e.g., 'myapp').
affects: >=9.80
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'ibapi'
ibapi is not installed or installed in wrong environment.
fix
Run 'pip install ibapi' and ensure you are using the correct Python interpreter (check with 'which python').
AttributeError: module 'ibapi' has no attribute 'client'
Importing ibapi.client (with dot) but wrong import path or missing submodule.
fix
Use 'from ibapi.client import EClient' instead of 'import ibapi.client'.
RuntimeError: Connect call failed: connection refused
TWS/IB Gateway not running or wrong host/port.
fix
Ensure TWS or IB Gateway is running and API connections enabled (File > Global Configuration > API > Enable ActiveX and Socket Clients). Default ports: 7497 (paper), 7496 (live).
Upgrade
Version history
9.81.1.post1latest on PyPI · released Dec 6, 2020
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
28
Resources
ibapi — pip install ibapi · libregistry