ib_async.wrapper
Generated from the installed ib_async 2.1.0 package. Signatures and defaults are version-specific.
Wrapper to handle incoming messages.
Public constants
| Name | Value |
|---|---|
EFP_TICK_MAP | {38: 'bidEfp', 39: 'askEfp', 40: 'lastEfp', 41: 'openEfp', 42: 'highEfp', 43: 'lowEfp', 44: 'closeEfp'} |
GENERIC_TICK_MAP | {23: 'histVolatility', 24: 'impliedVolatility', 31: 'indexFuturePremium', 46: 'shortable', 49: 'halted', 54: 'tradeCount', 55: 'tradeRate', 56: 'volumeRate', 58: 'rtHistVolatili... |
GREEKS_TICK_MAP | {10: 'bidGreeks', 80: 'bidGreeks', 11: 'askGreeks', 81: 'askGreeks', 12: 'lastGreeks', 82: 'lastGreeks', 13: 'modelGreeks', 83: 'modelGreeks', 53: 'custGreeks'} |
PRICE_TICK_MAP | {6: 'high', 72: 'high', 7: 'low', 73: 'low', 9: 'close', 75: 'close', 14: 'open', 76: 'open', 15: 'low13week', 16: 'high13week', 17: 'low26week', 18: 'high26week', 19: 'low52wee... |
RT_VOLUME_TICK_MAP | {48: 'rtVolume', 77: 'rtTradeVolume'} |
SIZE_TICK_MAP | {8: 'volume', 74: 'volume', 63: 'volumeRate3Min', 64: 'volumeRate5Min', 65: 'volumeRate10Min', 21: 'avVolume', 22: 'openInterest', 27: 'callOpenInterest', 28: 'putOpenInterest',... |
STRING_TICK_MAP | {25: 'optionBidExch', 26: 'optionAskExch', 32: 'bidExchange', 33: 'askExchange', 84: 'lastExchange', 85: 'lastRegTime', 91: 'reutersMutualFunds', 100: 'socialMarketAnalytics'} |
TIMESTAMP_TICK_MAP | {45: 'lastTimestamp', 88: 'delayedLastTimestamp'} |
TYPE_CHECKING | False |
UNSET_DOUBLE | 1.7976931348623157e+308 |
UNSET_INTEGER | 2147483647 |
RequestError
RequestError(reqId: int, code: int, message: str)
Exception to raise when the API reports an error that can be tied to a single request.
Wrapper
Wrapper(ib: 'IB', _logger: logging.Logger = <factory>, _timeoutHandle: asyncio.events.TimerHandle | None = None, defaults: ib_async.objects.IBDefaults = <factory>) -> None
Wrapper implementation for use with the IB class.
Fields
| Name | Type | Default |
|---|---|---|
ib | IB | required |
accountValues | dict | required |
acctSummary | dict | required |
portfolio | dict | required |
positions | dict | required |
trades | dict | required |
permId2Trade | dict | required |
fills | dict | required |
newsTicks | list | required |
msgId2NewsBulletin | dict | required |
tickers | dict | required |
pendingTickers | set | required |
reqId2Ticker | dict | required |
ticker2ReqId | dict | required |
reqId2Subscriber | dict | required |
reqId2PnL | dict | required |
reqId2PnlSingle | dict | required |
pnlKey2ReqId | dict | required |
pnlSingleKey2ReqId | dict | required |
lastTime | datetime | required |
time | float | required |
accounts | list | required |
clientId | int | required |
wshMetaReqId | int | required |
wshEventReqId | int | required |
_reqId2Contract | dict | required |
_timeout | float | required |
_futures | dict | required |
_results | dict | required |
_logger | Logger | factory: <lambda> |
_timeoutHandle | asyncio.events.TimerHandle | None | None |
defaults | IBDefaults | factory: IBDefaults |
accountDownloadEnd
accountDownloadEnd(self, _account: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
accountSummary
accountSummary(self, _reqId: int, account: str, tag: str, value: str, currency: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
accountSummaryEnd
accountSummaryEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
accountUpdateMulti
accountUpdateMulti(self, reqId: int, account: str, modelCode: str, tag: str, val: str, currency: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
accountUpdateMultiEnd
accountUpdateMultiEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
bondContractDetails
bondContractDetails(self, reqId: int, contractDetails: ib_async.contract.ContractDetails)
No library docstring is provided; consult the signature, type fields, and operational guides.
commissionReport
commissionReport(self, commissionReport: ib_async.objects.CommissionReport)
No library docstring is provided; consult the signature, type fields, and operational guides.
completedOrder
completedOrder(self, contract: ib_async.contract.Contract, order: ib_async.order.Order, orderState: ib_async.order.OrderState)
No library docstring is provided; consult the signature, type fields, and operational guides.
completedOrdersEnd
completedOrdersEnd(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
connectAck
connectAck(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
connectionClosed
connectionClosed(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
contractDetails
contractDetails(self, reqId: int, contractDetails: ib_async.contract.ContractDetails)
No library docstring is provided; consult the signature, type fields, and operational guides.
contractDetailsEnd
contractDetailsEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
currentTime
currentTime(self, time: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
deltaNeutralValidation
deltaNeutralValidation(self, reqId: int, dnc: ib_async.contract.DeltaNeutralContract)
No library docstring is provided; consult the signature, type fields, and operational guides.
dict
dict(obj) -> dict
Return dataclass values as dict.
This is a non-recursive variant of dataclasses.asdict.
endSubscription
endSubscription(self, subscriber)
Unregister a live subscription.
endTicker
endTicker(self, ticker: ib_async.ticker.Ticker, tickType: int | str)
No library docstring is provided; consult the signature, type fields, and operational guides.
error
error(self, reqId: int, errorCode: int, errorString: str, advancedOrderRejectJson: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
execDetails
execDetails(self, reqId: int, contract: ib_async.contract.Contract, execution: ib_async.objects.Execution)
This wrapper handles both live fills and responses to reqExecutions.
execDetailsEnd
execDetailsEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
familyCodes
familyCodes(self, familyCodes: list[ib_async.objects.FamilyCode])
No library docstring is provided; consult the signature, type fields, and operational guides.
fundamentalData
fundamentalData(self, reqId: int, data: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
headTimestamp
headTimestamp(self, reqId: int, headTimestamp: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
histogramData
histogramData(self, reqId: int, items: list[ib_async.objects.HistogramData])
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalData
historicalData(self, reqId: int, bar: ib_async.objects.BarData)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalDataEnd
historicalDataEnd(self, reqId, _start: str, _end: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalDataUpdate
historicalDataUpdate(self, reqId: int, bar: ib_async.objects.BarData)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalNews
historicalNews(self, reqId: int, time: str, providerCode: str, articleId: str, headline: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalNewsEnd
historicalNewsEnd(self, reqId, _hasMore: bool)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalSchedule
historicalSchedule(self, reqId: int, startDateTime: str, endDateTime: str, timeZone: str, sessions: list[ib_async.objects.HistoricalSession])
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalTicks
historicalTicks(self, reqId: int, ticks: list[ib_async.objects.HistoricalTick], done: bool)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalTicksBidAsk
historicalTicksBidAsk(self, reqId: int, ticks: list[ib_async.objects.HistoricalTickBidAsk], done: bool)
No library docstring is provided; consult the signature, type fields, and operational guides.
historicalTicksLast
historicalTicksLast(self, reqId: int, ticks: list[ib_async.objects.HistoricalTickLast], done: bool)
No library docstring is provided; consult the signature, type fields, and operational guides.
managedAccounts
managedAccounts(self, accountsList: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
marketDataType
marketDataType(self, reqId: int, marketDataId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
marketRule
marketRule(self, marketRuleId: int, priceIncrements: list[ib_async.objects.PriceIncrement])
No library docstring is provided; consult the signature, type fields, and operational guides.
mktDepthExchanges
mktDepthExchanges(self, depthMktDataDescriptions: list[ib_async.objects.DepthMktDataDescription])
No library docstring is provided; consult the signature, type fields, and operational guides.
newsArticle
newsArticle(self, reqId: int, articleType: int, articleText: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
newsProviders
newsProviders(self, newsProviders: list[ib_async.objects.NewsProvider])
No library docstring is provided; consult the signature, type fields, and operational guides.
nextValidId
nextValidId(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
nonDefaults
nonDefaults(obj) -> dict[str, typing.Any]
For a dataclass instance get the fields that are different from the
default values and return as dict.
openOrder
openOrder(self, orderId: int, contract: ib_async.contract.Contract, order: ib_async.order.Order, orderState: ib_async.order.OrderState)
This wrapper is called to:
- feed in open orders at startup;
- feed in open orders or order updates from other clients and TWS if clientId=master id;
- feed in manual orders and order updates from TWS if clientId=0;
- handle openOrders and allOpenOrders responses.
openOrderEnd
openOrderEnd(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
orderBound
orderBound(self, reqId: int, apiClientId: int, apiOrderId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
orderKey
orderKey(self, clientId: int, orderId: int, permId: int) -> int | tuple[int, int]
No library docstring is provided; consult the signature, type fields, and operational guides.
orderStatus
orderStatus(self, orderId: int, status: str, filled: float, remaining: float, avgFillPrice: float, permId: int, parentId: int, lastFillPrice: float, clientId: int, whyHeld: str, mktCapPrice: float = 0.0)
No library docstring is provided; consult the signature, type fields, and operational guides.
pnl
pnl(self, reqId: int, dailyPnL: float, unrealizedPnL: float, realizedPnL: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
pnlSingle
pnlSingle(self, reqId: int, pos: int, dailyPnL: float, unrealizedPnL: float, realizedPnL: float, value: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
position
position(self, account: str, contract: ib_async.contract.Contract, posSize: float, avgCost: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
positionEnd
positionEnd(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
positionMulti
positionMulti(self, reqId: int, account: str, modelCode: str, contract: ib_async.contract.Contract, pos: float, avgCost: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
positionMultiEnd
positionMultiEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
priceSizeTick
priceSizeTick(self, reqId: int, tickType: int, price: float, size: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
realtimeBar
realtimeBar(self, reqId: int, time: int, open_: float, high: float, low: float, close: float, volume: float, wap: float, count: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
receiveFA
receiveFA(self, _faDataType: int, faXmlData: str)
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.
scannerData
scannerData(self, reqId: int, rank: int, contractDetails: ib_async.contract.ContractDetails, distance: str, benchmark: str, projection: str, legsStr: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
scannerDataEnd
scannerDataEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
scannerParameters
scannerParameters(self, xml: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
securityDefinitionOptionParameter
securityDefinitionOptionParameter(self, reqId: int, exchange: str, underlyingConId: int, tradingClass: str, multiplier: str, expirations: list[str], strikes: list[float])
No library docstring is provided; consult the signature, type fields, and operational guides.
securityDefinitionOptionParameterEnd
securityDefinitionOptionParameterEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
setEventsDone
setEventsDone(self)
Set all subscription-type events as done.
setTimeout
setTimeout(self, timeout: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
smartComponents
smartComponents(self, reqId, components)
No library docstring is provided; consult the signature, type fields, and operational guides.
softDollarTiers
softDollarTiers(self, reqId: int, tiers: list[ib_async.objects.SoftDollarTier])
No library docstring is provided; consult the signature, type fields, and operational guides.
startReq
startReq(self, key, contract=None, container=None)
Start a new request and return the future that is associated with the key and container. The container is a list by default.
startSubscription
startSubscription(self, reqId, subscriber, contract=None)
Register a live subscription.
startTicker
startTicker(self, reqId: int, contract: ib_async.contract.Contract, tickType: int | str)
Start a tick request that has the reqId associated with the contract. Return the ticker.
symbolSamples
symbolSamples(self, reqId: int, contractDescriptions: list[ib_async.contract.ContractDescription])
No library docstring is provided; consult the signature, type fields, and operational guides.
tcpDataArrived
tcpDataArrived(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
tcpDataProcessed
tcpDataProcessed(self)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickByTickAllLast
tickByTickAllLast(self, reqId: int, tickType: int, time: int, price: float, size: float, tickAttribLast: ib_async.objects.TickAttribLast, exchange, specialConditions)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickByTickBidAsk
tickByTickBidAsk(self, reqId: int, time: int, bidPrice: float, askPrice: float, bidSize: float, askSize: float, tickAttribBidAsk: ib_async.objects.TickAttribBidAsk)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickByTickMidPoint
tickByTickMidPoint(self, reqId: int, time: int, midPoint: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickEFP
tickEFP(self, reqId: int, tickType: int, basisPoints: float, formattedBasisPoints: str, totalDividends: float, holdDays: int, futureLastTradeDate: str, dividendImpact: float, dividendsToLastTradeDate: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickGeneric
tickGeneric(self, reqId: int, tickType: int, value: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickNews
tickNews(self, _reqId: int, timeStamp: int, providerCode: str, articleId: str, headline: str, extraData: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickOptionComputation
tickOptionComputation(self, reqId: int, tickType: int, tickAttrib: int, impliedVol: float, delta: float, optPrice: float, pvDividend: float, gamma: float, vega: float, theta: float, undPrice: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickReqParams
tickReqParams(self, reqId: int, minTick: float, bboExchange: str, snapshotPermissions: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickSize
tickSize(self, reqId: int, tickType: int, size: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickSnapshotEnd
tickSnapshotEnd(self, reqId: int)
No library docstring is provided; consult the signature, type fields, and operational guides.
tickString
tickString(self, reqId: int, tickType: int, value: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
tuple
tuple(obj) -> tuple[typing.Any, ...]
Return dataclass values as tuple.
This is a non-recursive variant of dataclasses.astuple.
update
update(obj, *srcObjs, **kwargs) -> object
Update fields of the given dataclass object from zero or more
dataclass source objects and/or from keyword arguments.
updateAccountTime
updateAccountTime(self, timestamp: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateAccountValue
updateAccountValue(self, tag: str, val: str, currency: str, account: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateMktDepth
updateMktDepth(self, reqId: int, position: int, operation: int, side: int, price: float, size: float)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateMktDepthL2
updateMktDepthL2(self, reqId: int, position: int, marketMaker: str, operation: int, side: int, price: float, size: float, isSmartDepth: bool = False)
No library docstring is provided; consult the signature, type fields, and operational guides.
updateNewsBulletin
updateNewsBulletin(self, msgId: int, msgType: int, message: str, origExchange: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
updatePortfolio
updatePortfolio(self, contract: ib_async.contract.Contract, posSize: float, marketPrice: float, marketValue: float, averageCost: float, unrealizedPNL: float, realizedPNL: float, account: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
userInfo
userInfo(self, reqId: int, whiteBrandingId: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
wshEventData
wshEventData(self, reqId: int, dataJson: str)
No library docstring is provided; consult the signature, type fields, and operational guides.
wshMetaData
wshMetaData(self, reqId: int, dataJson: str)
No library docstring is provided; consult the signature, type fields, and operational guides.