ib_async.client
Generated from the installed ib_async 2.1.0 package. Signatures and defaults are version-specific.
Socket client for communicating with Interactive Brokers.
Public constants
| Name | Value |
|---|---|
UNSET_DOUBLE | 1.7976931348623157e+308 |
UNSET_INTEGER | 2147483647 |
Client
Client(wrapper)
Replacement for ibapi.client.EClient that uses asyncio.
The client is fully asynchronous and has its own
event-driven networking code that replaces the
networking code of the standard EClient.
It also replaces the infinite loop of EClient.run()
with the asyncio event loop. It can be used as a drop-in
replacement for the standard EClient as provided by IBAPI.
Compared to the standard EClient this client has the following additional features:
-
client.connect()will block until the client is ready to serve requests; It is not necessary to wait fornextValidIdto start requests as the client has already done that. The reqId is directly available with :py.getReqId(). -
client.connectAsync()is a coroutine for connecting asynchronously. -
When blocking,
client.connect()can be made to time out with the timeout parameter (default 2 seconds). -
Optional
wrapper.priceSizeTick(reqId, tickType, price, size)that combines price and size instead of the two wrapper methods priceTick and sizeTick. -
Automatic request throttling.
-
Optional
wrapper.tcpDataArrived()method; If the wrapper has this method it is invoked directly after a network packet has arrived. A possible use is to timestamp all data in the packet with the exact same time. -
Optional
wrapper.tcpDataProcessed()method; If the wrapper has this method it is invoked after the network packet's data has been handled. A possible use is to write or evaluate the newly arrived data in one batch instead of item by item.
Parameters:
MaxRequests (int):
Throttle the number of requests to MaxRequests per
RequestsInterval seconds. Set to 0 to disable throttling.
RequestsInterval (float):
Time interval (in seconds) for request throttling.
MinClientVersion (int):
Client protocol version.
MaxClientVersion (int):
Client protocol version.
Events:
apiStart()apiEnd()apiError(errorMsg: str)throttleStart()throttleEnd()
calculateImpliedVolatility
calculateImpliedVolatility(self, reqId, contract, optionPrice, underPrice, implVolOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
calculateOptionPrice
calculateOptionPrice(self, reqId, contract, volatility, underPrice, optPrcOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelAccountSummary
cancelAccountSummary(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelAccountUpdatesMulti
cancelAccountUpdatesMulti(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelCalculateImpliedVolatility
cancelCalculateImpliedVolatility(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelCalculateOptionPrice
cancelCalculateOptionPrice(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelFundamentalData
cancelFundamentalData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelHeadTimeStamp
cancelHeadTimeStamp(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelHistogramData
cancelHistogramData(self, tickerId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelHistoricalData
cancelHistoricalData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelMktData
cancelMktData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelMktDepth
cancelMktDepth(self, reqId, isSmartDepth)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelNewsBulletins
cancelNewsBulletins(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelOrder
cancelOrder(self, orderId, manualCancelOrderTime='')
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelPnL
cancelPnL(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelPnLSingle
cancelPnLSingle(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelPositions
cancelPositions(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelPositionsMulti
cancelPositionsMulti(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelRealTimeBars
cancelRealTimeBars(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelScannerSubscription
cancelScannerSubscription(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelTickByTickData
cancelTickByTickData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelWshEventData
cancelWshEventData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
cancelWshMetaData
cancelWshMetaData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
connect
connect(self, host: str, port: int, clientId: int, timeout: float | None = 2.0)
Connect to a running TWS or IB gateway application.
Args:
host: Host name or IP address.
port: Port number.
clientId: ID number to use for this client; must be unique per
connection.
timeout: If establishing the connection takes longer than
timeout seconds then the asyncio.TimeoutError exception
is raised. Set to 0 to disable timeout.
connectAsync
connectAsync(self, host, port, clientId, timeout=2.0)
No library docstring is provided; consult the signature, type fields, and operational guides.
connectionStats
connectionStats(self) -> ib_async.objects.ConnectionStats
Get statistics about the connection.
disconnect
disconnect(self)
Disconnect from IB connection.
exerciseOptions
exerciseOptions(self, reqId, contract, exerciseAction, exerciseQuantity, account, override)
No library docstring is provided; consult the signature, type fields, and operational guides.
getAccounts
getAccounts(self) -> list[str]
Get the list of account names that are under management.
getReqId
getReqId(self) -> int
Get new request ID.
isConnected
isConnected(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
isReady
isReady(self) -> bool
Is the API connection up and running?
placeOrder
placeOrder(self, orderId, contract, order)
No library docstring is provided; consult the signature, type fields, and operational guides.
queryDisplayGroups
queryDisplayGroups(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
replaceFA
replaceFA(self, reqId, faData, cxml)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqAccountSummary
reqAccountSummary(self, reqId, groupName, tags)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqAccountUpdates
reqAccountUpdates(self, subscribe, acctCode)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqAccountUpdatesMulti
reqAccountUpdatesMulti(self, reqId, account, modelCode, ledgerAndNLV)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqAllOpenOrders
reqAllOpenOrders(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqAutoOpenOrders
reqAutoOpenOrders(self, bAutoBind)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqCompletedOrders
reqCompletedOrders(self, apiOnly)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqContractDetails
reqContractDetails(self, reqId, contract)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqCurrentTime
reqCurrentTime(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqExecutions
reqExecutions(self, reqId, execFilter)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqFamilyCodes
reqFamilyCodes(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqFundamentalData
reqFundamentalData(self, reqId, contract, reportType, fundamentalDataOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqGlobalCancel
reqGlobalCancel(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqHeadTimeStamp
reqHeadTimeStamp(self, reqId, contract, whatToShow, useRTH, formatDate)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqHistogramData
reqHistogramData(self, tickerId, contract, useRTH, timePeriod)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqHistoricalData
reqHistoricalData(self, reqId, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, keepUpToDate, chartOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqHistoricalNews
reqHistoricalNews(self, reqId, conId, providerCodes, startDateTime, endDateTime, totalResults, historicalNewsOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqHistoricalTicks
reqHistoricalTicks(self, reqId, contract, startDateTime, endDateTime, numberOfTicks, whatToShow, useRth, ignoreSize, miscOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqIds
reqIds(self, numIds)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqManagedAccts
reqManagedAccts(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMarketDataType
reqMarketDataType(self, marketDataType)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMarketRule
reqMarketRule(self, marketRuleId)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMatchingSymbols
reqMatchingSymbols(self, reqId, pattern)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMktData
reqMktData(self, reqId, contract, genericTickList, snapshot, regulatorySnapshot, mktDataOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMktDepth
reqMktDepth(self, reqId, contract, numRows, isSmartDepth, mktDepthOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqMktDepthExchanges
reqMktDepthExchanges(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqNewsArticle
reqNewsArticle(self, reqId, providerCode, articleId, newsArticleOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqNewsBulletins
reqNewsBulletins(self, allMsgs)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqNewsProviders
reqNewsProviders(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqOpenOrders
reqOpenOrders(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqPnL
reqPnL(self, reqId, account, modelCode)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqPnLSingle
reqPnLSingle(self, reqId, account, modelCode, conid)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqPositions
reqPositions(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqPositionsMulti
reqPositionsMulti(self, reqId, account, modelCode)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqRealTimeBars
reqRealTimeBars(self, reqId, contract, barSize, whatToShow, useRTH, realTimeBarsOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqScannerParameters
reqScannerParameters(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqScannerSubscription
reqScannerSubscription(self, reqId, subscription, scannerSubscriptionOptions, scannerSubscriptionFilterOptions)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqSecDefOptParams
reqSecDefOptParams(self, reqId, underlyingSymbol, futFopExchange, underlyingSecType, underlyingConId)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqSmartComponents
reqSmartComponents(self, reqId, bboExchange)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqSoftDollarTiers
reqSoftDollarTiers(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqTickByTickData
reqTickByTickData(self, reqId, contract, tickType, numberOfTicks, ignoreSize)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqUserInfo
reqUserInfo(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqWshEventData
reqWshEventData(self, reqId, data: ib_async.objects.WshEventData)
No library docstring is provided; consult the signature, type fields, and operational guides.
reqWshMetaData
reqWshMetaData(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
requestFA
requestFA(self, faData)
No library docstring is provided; consult the signature, type fields, and operational guides.
reset
reset(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
run
run(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
send
send(self, *fields, makeEmpty=True)
Serialize and send the given fields using the IB socket protocol.
if 'makeEmpty' is True (default), then the IBKR values representing "no value" become the empty string.
sendMsg
sendMsg(self, msg: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
serverVersion
serverVersion(self) -> int
No library docstring is provided; consult the signature, type fields, and operational guides.
setConnectOptions
setConnectOptions(self, connectOptions: str)
Set additional connect options.
Args: connectOptions: Use "+PACEAPI" to use request-pacing built into TWS/gateway 974+ (obsolete).
setServerLogLevel
setServerLogLevel(self, logLevel)
No library docstring is provided; consult the signature, type fields, and operational guides.
startApi
startApi(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
subscribeToGroupEvents
subscribeToGroupEvents(self, reqId, groupId)
No library docstring is provided; consult the signature, type fields, and operational guides.
unsubscribeFromGroupEvents
unsubscribeFromGroupEvents(self, reqId)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateDisplayGroup
updateDisplayGroup(self, reqId, contractInfo)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateReqId
updateReqId(self, minReqId)
Update the next reqId to be at least minReqId.
verifyAndAuthMessage
verifyAndAuthMessage(self, apiData, xyzResponse)
No library docstring is provided; consult the signature, type fields, and operational guides.
verifyAndAuthRequest
verifyAndAuthRequest(self, apiName, apiVersion, opaqueIsvKey)
No library docstring is provided; consult the signature, type fields, and operational guides.
verifyMessage
verifyMessage(self, apiData)
No library docstring is provided; consult the signature, type fields, and operational guides.
verifyRequest
verifyRequest(self, apiName, apiVersion)
No library docstring is provided; consult the signature, type fields, and operational guides.