ib-underscore-async-underscore-modules-ib-underscore-async-objects.md
"""Object hierarchy."""from \_\_future\_\_ importannotationsfrom dataclasses importdataclass,fieldfrom datetime importdateasdate\_from datetime importdatetime,timezone,tzinfofrom typing importAny,NamedTuplefrom eventkit importEventfrom .contract importContract,ScanData,TagValuefrom .util importEPOCH,UNSET\_DOUBLE,UNSET\_INTEGERnan=float("nan")
[[docs]](../../api.html#ib_async.objects.ScannerSubscription)@dataclassclass ScannerSubscription:numberOfRows: int = -1instrument: str = ""locationCode: str = ""scanCode: str = ""abovePrice: float = UNSET\_DOUBLEbelowPrice: float = UNSET\_DOUBLEaboveVolume: int = UNSET\_INTEGERmarketCapAbove: float = UNSET\_DOUBLEmarketCapBelow: float = UNSET\_DOUBLEmoodyRatingAbove: str = ""moodyRatingBelow: str = ""spRatingAbove: str = ""spRatingBelow: str = ""maturityDateAbove: str = ""maturityDateBelow: str = ""couponRateAbove: float = UNSET\_DOUBLEcouponRateBelow: float = UNSET\_DOUBLEexcludeConvertible: bool = FalseaverageOptionVolumeAbove: int = UNSET\_INTEGERscannerSettingPairs: str = ""stockTypeFilter: str = ""
[[docs]](../../api.html#ib_async.objects.SoftDollarTier)@dataclassclass SoftDollarTier:name: str = ""val: str = ""displayName: str = ""def \_\_bool\_\_(self):return bool(self.name or self.val or self.displayName)
[[docs]](../../api.html#ib_async.objects.Execution)@dataclassclass Execution:execId: str = ""time: datetime = field(default=EPOCH)acctNumber: str = ""exchange: str = ""side: str = ""shares: float = 0.0price: float = 0.0permId: int = 0clientId: int = 0orderId: int = 0liquidation: int = 0cumQty: float = 0.0avgPrice: float = 0.0orderRef: str = ""evRule: str = ""evMultiplier: float = 0.0modelCode: str = ""lastLiquidity: int = 0pendingPriceRevision: bool = False
[[docs]](../../api.html#ib_async.objects.CommissionReport)@dataclassclass CommissionReport:execId: str = ""commission: float = 0.0currency: str = ""realizedPNL: float = 0.0yield\_: float = 0.0yieldRedemptionDate: int = 0
[[docs]](../../api.html#ib_async.objects.ExecutionFilter)@dataclassclass ExecutionFilter:clientId: int = 0acctCode: str = ""time: str = ""symbol: str = ""secType: str = ""exchange: str = ""side: str = ""
[[docs]](../../api.html#ib_async.objects.BarData)@dataclassclass BarData:date: date\_ | datetime = EPOCHopen: float = 0.0high: float = 0.0low: float = 0.0close: float = 0.0volume: float = 0average: float = 0.0barCount: int = 0
[[docs]](../../api.html#ib_async.objects.RealTimeBar)@dataclassclass RealTimeBar:time: datetime = EPOCHendTime: int = -1open\_: float = 0.0high: float = 0.0low: float = 0.0close: float = 0.0volume: float = 0.0wap: float = 0.0count: int = 0
[[docs]](../../api.html#ib_async.objects.TickAttrib)@dataclassclass TickAttrib:canAutoExecute: bool = FalsepastLimit: bool = FalsepreOpen: bool = False
[[docs]](../../api.html#ib_async.objects.TickAttribBidAsk)@dataclassclass TickAttribBidAsk:bidPastLow: bool = FalseaskPastHigh: bool = False
[[docs]](../../api.html#ib_async.objects.TickAttribLast)@dataclassclass TickAttribLast:pastLimit: bool = Falseunreported: bool = False
[[docs]](../../api.html#ib_async.objects.HistogramData)@dataclassclass HistogramData:price: float = 0.0count: int = 0
[[docs]](../../api.html#ib_async.objects.NewsProvider)@dataclassclass NewsProvider:code: str = ""name: str = ""
[[docs]](../../api.html#ib_async.objects.DepthMktDataDescription)@dataclassclass DepthMktDataDescription:exchange: str = ""secType: str = ""listingExch: str = ""serviceDataType: str = ""aggGroup: int = UNSET\_INTEGER
[[docs]](../../api.html#ib_async.objects.PnL)@dataclassclass PnL:account: str = ""modelCode: str = ""dailyPnL: float = nanunrealizedPnL: float = nanrealizedPnL: float = nan
[[docs]](../../api.html#ib_async.objects.TradeLogEntry)@dataclassclass TradeLogEntry:time: datetimestatus: str = ""message: str = ""errorCode: int = 0
[[docs]](../../api.html#ib_async.objects.PnLSingle)@dataclassclass PnLSingle:account: str = ""modelCode: str = ""conId: int = 0dailyPnL: float = nanunrealizedPnL: float = nanrealizedPnL: float = nanposition: int = 0value: float = nan
[[docs]](../../api.html#ib_async.objects.HistoricalSession)@dataclassclass HistoricalSession:startDateTime: str = ""endDateTime: str = ""refDate: str = ""
[[docs]](../../api.html#ib_async.objects.HistoricalSchedule)@dataclassclass HistoricalSchedule:startDateTime: str = ""endDateTime: str = ""timeZone: str = ""sessions: list[HistoricalSession] = field(default\_factory=list)
[[docs]](../../api.html#ib_async.objects.WshEventData)@dataclassclass WshEventData:conId: int = UNSET\_INTEGERfilter: str = ""fillWatchlist: bool = FalsefillPortfolio: bool = FalsefillCompetitors: bool = FalsestartDate: str = ""endDate: str = ""totalLimit: int = UNSET\_INTEGER
[[docs]](../../api.html#ib_async.objects.AccountValue)class AccountValue(NamedTuple):account: strtag: strvalue: strcurrency: strmodelCode: str
[[docs]](../../api.html#ib_async.objects.TickData)class TickData(NamedTuple):time: datetimetickType: intprice: floatsize: float
[[docs]](../../api.html#ib_async.objects.HistoricalTick)class HistoricalTick(NamedTuple):time: datetimeprice: floatsize: float
[[docs]](../../api.html#ib_async.objects.HistoricalTickBidAsk)class HistoricalTickBidAsk(NamedTuple):time: datetimetickAttribBidAsk: TickAttribBidAskpriceBid: floatpriceAsk: floatsizeBid: floatsizeAsk: float
[[docs]](../../api.html#ib_async.objects.HistoricalTickLast)class HistoricalTickLast(NamedTuple):time: datetimetickAttribLast: TickAttribLastprice: floatsize: floatexchange: strspecialConditions: str
[[docs]](../../api.html#ib_async.objects.TickByTickAllLast)class TickByTickAllLast(NamedTuple):tickType: inttime: datetimeprice: floatsize: floattickAttribLast: TickAttribLastexchange: strspecialConditions: str
[[docs]](../../api.html#ib_async.objects.TickByTickBidAsk)class TickByTickBidAsk(NamedTuple):time: datetimebidPrice: floataskPrice: floatbidSize: floataskSize: floattickAttribBidAsk: TickAttribBidAsk
[[docs]](../../api.html#ib_async.objects.TickByTickMidPoint)class TickByTickMidPoint(NamedTuple):time: datetimemidPoint: float
[[docs]](../../api.html#ib_async.objects.MktDepthData)class MktDepthData(NamedTuple):time: datetimeposition: intmarketMaker: stroperation: intside: intprice: floatsize: float
[[docs]](../../api.html#ib_async.objects.DOMLevel)class DOMLevel(NamedTuple):price: floatsize: floatmarketMaker: str
[[docs]](../../api.html#ib_async.objects.PriceIncrement)class PriceIncrement(NamedTuple):lowEdge: floatincrement: float
[[docs]](../../api.html#ib_async.objects.PortfolioItem)class PortfolioItem(NamedTuple):contract: Contractposition: floatmarketPrice: floatmarketValue: floataverageCost: floatunrealizedPNL: floatrealizedPNL: floataccount: str
[[docs]](../../api.html#ib_async.objects.Position)class Position(NamedTuple):account: strcontract: Contractposition: floatavgCost: float
[[docs]](../../api.html#ib_async.objects.Fill)class Fill(NamedTuple):contract: Contractexecution: ExecutioncommissionReport: CommissionReporttime: datetime
[[docs]](../../api.html#ib_async.objects.EfpData)@dataclass(slots=True, frozen=True)class EfpData:""" Exchange for Physical (EFP) futures data. EFP allows trading a position in a single stock for a position in the corresponding single stock future. """# Annualized basis points (financing rate comparable to broker rates)basisPoints: float# Basis points formatted as percentage stringformattedBasisPoints: str# The implied Futures priceimpliedFuture: float# Number of days until the future's last trade dateholdDays: int# Expiration date of the single stock futurefutureLastTradeDate: str# Dividend impact on the annualized basis points interest ratedividendImpact: float# Expected dividends until future expirationdividendsToLastTradeDate: float
[[docs]](../../api.html#ib_async.objects.OptionComputation)@dataclass(slots=True, frozen=True)class OptionComputation:tickAttrib: intimpliedVol: float | None = Nonedelta: float | None = NoneoptPrice: float | None = NonepvDividend: float | None = Nonegamma: float | None = Nonevega: float | None = Nonetheta: float | None = NoneundPrice: float | None = Nonedef \_\_add\_\_(self, other: OptionComputation) -\> OptionComputation:if not isinstance(other, self.\_\_class\_\_):raise TypeError(f"Cannot add {type(self)} and {type(other)}")return self.\_\_class\_\_(tickAttrib=0,impliedVol=(self.impliedVol or 0) + (other.impliedVol or 0),delta=(self.delta or 0) + (other.delta or 0),optPrice=(self.optPrice or 0) + (other.optPrice or 0),gamma=(self.gamma or 0) + (other.gamma or 0),vega=(self.vega or 0) + (other.vega or 0),theta=(self.theta or 0) + (other.theta or 0),undPrice=self.undPrice,)def \_\_sub\_\_(self, other: OptionComputation) -\> OptionComputation:if not isinstance(other, self.\_\_class\_\_):raise TypeError(f"Cannot subtract {type(self)} and {type(other)}")return self.\_\_class\_\_(tickAttrib=0,impliedVol=(self.impliedVol or 0) - (other.impliedVol or 0),delta=(self.delta or 0) - (other.delta or 0),optPrice=(self.optPrice or 0) - (other.optPrice or 0),gamma=(self.gamma or 0) - (other.gamma or 0),vega=(self.vega or 0) - (other.vega or 0),theta=(self.theta or 0) - (other.theta or 0),undPrice=self.undPrice,)def \_\_mul\_\_(self, other: int | float) -\> OptionComputation:if not isinstance(other, int | float):raise TypeError(f"Cannot multiply {type(self)} and {type(other)}")return self.\_\_class\_\_(tickAttrib=0,impliedVol=(self.impliedVol or 0) \* other,delta=(self.delta or 0) \* other,optPrice=(self.optPrice or 0) \* other,gamma=(self.gamma or 0) \* other,vega=(self.vega or 0) \* other,theta=(self.theta or 0) \* other,undPrice=self.undPrice,)
[[docs]](../../api.html#ib_async.objects.OptionChain)@dataclass(slots=True, frozen=True)class OptionChain:exchange: strunderlyingConId: inttradingClass: strmultiplier: strexpirations: list[str]strikes: list[float]
[[docs]](../../api.html#ib_async.objects.Dividends)@dataclass(slots=True, frozen=True)class Dividends:past12Months: float | Nonenext12Months: float | NonenextDate: date\_ | NonenextAmount: float | None
[[docs]](../../api.html#ib_async.objects.NewsArticle)@dataclass(slots=True, frozen=True)class NewsArticle:articleType: intarticleText: str
[[docs]](../../api.html#ib_async.objects.HistoricalNews)@dataclass(slots=True, frozen=True)class HistoricalNews:time: datetimeproviderCode: strarticleId: strheadline: str
[[docs]](../../api.html#ib_async.objects.NewsTick)@dataclass(slots=True, frozen=True)class NewsTick:timeStamp: intproviderCode: strarticleId: strheadline: strextraData: str
[[docs]](../../api.html#ib_async.objects.NewsBulletin)@dataclass(slots=True, frozen=True)class NewsBulletin:msgId: intmsgType: intmessage: strorigExchange: str
[[docs]](../../api.html#ib_async.objects.FamilyCode)@dataclass(slots=True, frozen=True)class FamilyCode:accountID: strfamilyCodeStr: str
[[docs]](../../api.html#ib_async.objects.SmartComponent)@dataclass(slots=True, frozen=True)class SmartComponent:bitNumber: intexchange: strexchangeLetter: str
[[docs]](../../api.html#ib_async.objects.ConnectionStats)@dataclass(slots=True, frozen=True)class ConnectionStats:startTime: floatduration: floatnumBytesRecv: intnumBytesSent: intnumMsgRecv: intnumMsgSent: int
[[docs]](../../api.html#ib_async.objects.BarDataList)class BarDataList(list[BarData]):""" List of :class:`.BarData` that also stores all request parameters. Events: \* ``updateEvent`` (bars: :class:`.BarDataList`, hasNewBar: bool) """reqId: intcontract: ContractendDateTime: datetime | date\_ | str | NonedurationStr: strbarSizeSetting: strwhatToShow: struseRTH: boolformatDate: intkeepUpToDate: boolchartOptions: list[TagValue]def \_\_init\_\_(self, \*args):super().\_\_init\_\_(\*args)self.updateEvent = Event("updateEvent")def \_\_eq\_\_(self, other) -\> bool:return self is other
[[docs]](../../api.html#ib_async.objects.RealTimeBarList)class RealTimeBarList(list[RealTimeBar]):""" List of :class:`.RealTimeBar` that also stores all request parameters. Events: \* ``updateEvent`` (bars: :class:`.RealTimeBarList`, hasNewBar: bool) """reqId: intcontract: ContractbarSize: intwhatToShow: struseRTH: boolrealTimeBarsOptions: list[TagValue]def \_\_init\_\_(self, \*args):super().\_\_init\_\_(\*args)self.updateEvent = Event("updateEvent")def \_\_eq\_\_(self, other) -\> bool:return self is other
[[docs]](../../api.html#ib_async.objects.ScanDataList)class ScanDataList(list[ScanData]):""" List of :class:`.ScanData` that also stores all request parameters. Events: \* ``updateEvent`` (:class:`.ScanDataList`) """reqId: intsubscription: ScannerSubscriptionscannerSubscriptionOptions: list[TagValue]scannerSubscriptionFilterOptions: list[TagValue]def \_\_init\_\_(self, \*args):super().\_\_init\_\_(\*args)self.updateEvent = Event("updateEvent")def \_\_eq\_\_(self, other):return self is other
[[docs]](../../api.html#ib_async.objects.DynamicObject)class DynamicObject:def \_\_init\_\_(self, \*\*kwargs):self.\_\_dict\_\_.update(kwargs)def \_\_repr\_\_(self):clsName = self.\_\_class\_\_.\_\_name\_\_kwargs = ", ".join(f"{k}={v!r}" for k, v in self.\_\_dict\_\_.items())return f"{clsName}({kwargs})"
[[docs]](../../api.html#ib_async.objects.FundamentalRatios)class FundamentalRatios(DynamicObject):""" See: https://web.archive.org/web/20200725010343/https://interactivebrokers.github.io/tws-api/fundamental\_ratios\_tags.html """pass
[[docs]](../../api.html#ib_async.objects.IBDefaults)@dataclassclass IBDefaults:"""A simple way to provide default values when populating API data."""# optionally replace IBKR using -1 price and 0 size when quotes don't existemptyPrice: Any = -1emptySize: Any = 0# optionally replace ib\_async default for all instance variable values before popualted from API updatesunset: Any = nan# optionally change the timezone used for log history events in objects (no impact on orders or data processing)timezone: tzinfo = timezone.utc