Create a IB API object.
Optional
options: IBApiCreationOptionsCreation options.
Private
controllerThe I/O queue controller object.
Static
prefixedReturns true
if currently connected to server, false
otherwise.
Get the IB API Server version.
[[MIN_SERVER_VER]]
Calculate the volatility for an option. Request the calculation of the implied volatility based on hypothetical option and its underlying prices. The calculation will be emitted as tickOptionComputation event.
Unique identifier of the request.
The option's contract for which the volatility wants to be calculated.
Hypothetical option price.
Hypothetical option's underlying price.
[[cancelCalculateImpliedVolatility]]
Calculates an option's price based on the provided volatility and its underlying price. The calculation will be emitted as tickOptionComputation event.
Unique identifier of the request.
The option's contract for which the price wants to be calculated.
Hypothetical volatility.
Hypothetical underlying price.
[[cancelCalculateOptionPrice]]
Exercises an options contract.
Note: this function is affected by a TWS setting which specifies if an exercise request must be finalized.
The exercise request's identifier.
The option [[Contract]] to be exercised.
1 to exercise the option, 2 to let the option lapse.
Number of contracts to be exercised.
Destination account.
Specifies whether your setting will override the system's natural action. For example, if your action is "exercise" and the option is not in-the-money, by natural action the option would not exercise. If you have override set to "yes" the natural action would be overridden and the out-of-the money option would be exercised. Set to 1 to override, set to 0 not to.
Notifies when an event has been received (called for the any type for event).
event: Name of the event.
arguments: event arguments.
Notifies when the connection to TWS/IB Gateway has been established successfully.
Notification callback.
[[connect]]
Notifies that the TCP socket connection to the TWS/IB Gateway has been disconnected.
Notification callback.
[[disconnect]]
Provides status information messages for development / logging purpose.
message: Message text. code: Message code.
Notifies about an error and TCP socket connection to the TWS/IB Gateway.
disconnected
event will arrive soon afterwards.
error: The error details.
code: The code identifying the error.
reqId: The request identifier which generated the error.
Optional
advancedOrderReject: unknownNotifies about the API server version.
Will arrive soon after connected
event.
serverVersion: The server version.
serverConnectionTime: The connection time.
[[connect]]
Notifies when data has been received from the server.
tokens: Array of received tokens.
Notifies when data is sent to the server.
tokens: Array of token to be sent.
Notifies about the the result to request.
event: Name of the event.
arguments: event arguments.
Notifies when all the account's information has finished.
account: The account's id
[[reqAccountUpdates]]
Receives the account information. This method will receive the account information just as it appears in the TWS' Account Summary Window.
reqID: The request's unique identifier.
account: The account id.
tag: The account's attribute being received. Possible values:
value: the account's attribute's value.
[[reqAccountSummary]]
Notifies when all the accounts' information has ben received.
Requires TWS 967+ to receive accountSummaryEnd in linked account structures.
reqID: The request's unique identifier.
[[reqAccountSummary]]
Provides the account updates.
requestId: The id of request.
account: The account with updates.
modelCode: The model code with updates.
key: The name of parameter.
value: The value of parameter.
currency: The currency of parameter.
[[reqAccountUpdatesMulti]]
Indicates all the account updates have been transmitted.
requestId: The id of request.
[[reqAccountUpdatesMulti]]
Delivers the Bond contract data after this has been requested via reqContractDetails.
reqId: The request's identifier.
contract: The bond contract's information.
[[reqAccountUpdatesMulti]]
Provides the [[CommissionReport]] of an [[Execution]]
commissionReport: The commission report.
[[reqExecutions]]
Feeds in completed orders.
contract: The order's [[Contract]].
order: The completed [[Order]].
orderState: The order's [[OrderState]].
[[reqCompletedOrders]]
Notifies the end of the completed orders' reception.
Completion callback function.
[[reqCompletedOrders]]
Returns meta data from the WSH calendar.
reqId: The unique request identifier.
dataJson: metadata in json format
[[reqWshMetaData]]
Returns calendar events from the WSH.
reqId: The unique request identifier.
dataJson: event data in json format
[[reqWshEventData]]
Callback to indicate the API connection has closed. Following a API <-> TWS broken socket connection, this function is not called automatically but must be triggered by API client code.
Connection closed callback function.
[[disconnect]]
Receives the full contract's definitions. This method will return all contracts matching the requested via [[reqContractDetails]] For example, one can obtain the whole option chain with it.
reqId: The unique request identifier.
contractDetails: The instrument's complete definition.
[[reqContractDetails]]
After all contracts matching the request were returned, this method will mark the end of their reception.
reqId: the request's identifier
[[reqContractDetails]]
TWS's current time.
TWS is synchronized with the server (not local computer) using NTP and this function will receive the current time in TWS.
time: The current time in TWS.
[[reqCurrentTime]]
Upon accepting a Delta-Neutral DN RFQ(request for quote), the server sends a deltaNeutralValidation
message
with the [[DeltaNeutralContract]]structure.
If the delta and price fields are empty in the original request, the confirmation will contain the current
values from the server. These values are locked when RFQ is processed and remain locked until the RFQ is cancelled.
reqId: The request's identifier.
deltaNeutralContract Delta-Neutral [[Contract]].
When requesting market data snapshots, this market will indicate the snapshot reception is finished.
Expected to occur 11 seconds after beginning of request.
reqId: The request's identifier.
Returns the market data type (real-time, frozen, delayed, delayed-frozen) of ticker sent by [[reqMktData]] when TWS switches from real-time to frozen and back and from delayed to delayed-frozen and back.
reqId: The request's identifier.
marketDataType: Signals that now API starts to tick with the following market data:
A one-time response to querying the display groups.
reqId: The ID of the request.
groups: A list of integers representing visible Group ID separated by the "|" character, and sorted by most used group first.
[[queryDisplayGroups]]
Call triggered once after receiving the subscription request, and will be sent again if the selected contract in the subscribed display group has changed.
reqId: The ID of the request.
contractInfo: The contract information.
[[subscribeToGroupEvents]]
Handles errors generated within the API itself.
If an exception is thrown within the API code it will be notified here. Possible cases include errors while reading the information from the socket or even mishandling at API implementation.
error: The thrown exception.
Errors sent by the TWS are received here.
If an exception is thrown within the API code it will be notified here. Possible cases include errors while reading the information from the socket or even mishandling at API implementation.
id: The request identifier which generated the error. Note: -1 will indicate a notification and not true error condition.
errorCode: The code identifying the error.
errorMsg: Error's description. Currently Latin-1 encoded error messages are supported. If logged into TWS in a different language it is recommended to enabled the setting in TWS Global Configuration -> API -> Settings -> Show API errors in English.
Optional
advancedOrderReject: unknownProvides the executions which happened in the last 24 hours.
reqId: The request's identifier.
contract: The [[Contract]] of the [[Order]].
execution: The [[Execution]] details.
[[reqExecutions]]
Indicates the end of the [[Execution]] reception.
reqId The request's identifier.
[[reqExecutions]]
Returns array of family codes.
familyCodes Array of family codes.
[[reqFamilyCodes]]
Returns array of sample contract descriptions.
contractDescriptions Array of contract descriptions.
[[reqFamilyCodes]]
Returns fundamental data.
reqId: The request's identifier.
data: xml-formatted fundamental data.
[[reqFundamentalData]]
Returns beginning of data for contract for specified data type.
reqId: The request's identifier.
headTimestamp: string identifying earliest data.
[[reqHeadTimestamp]]
Returns data histogram.
reqId: The request's identifier.
data: Tuple of histogram data, number of trades at specified price level.
[[reqHistogramData]]
Returns the requested historical data bars.
reqId: the request's identifier
time: the time the bar represents open: price at open of time period high: high price during time period low: low price during time period close: price at close of time period volume: share volume during time period count: trade count during time period WAP: weighted average price hasGaps: identifies whether or not there are gaps in the data. The time zone of the bar is the time zone chosen on the TWS login screen. Smallest bar size is 1 second.
https://interactivebrokers.github.io/tws-api/historical_bars.html#hd_what_to_show for additional context regarding meaning of price for different bar types
Receives bars in real time if keepUpToDate is true
in reqHistoricalData.
Similar to realTimeBars function, except returned data is a composite of historical data and
real time data that is equivalent to TWS chart functionality to keep charts up to date.
Returned bars are successfully updated using real time data.
reqId: The request's identifier.
time: the time the bar represents open: price at open of time period high: high price during time period low: low price during time period close: price at close of time period volume: share volume during time period count: trade count during time period WAP: weighted average price The time zone of the bar is the time zone chosen on the TWS login screen. Smallest bar size is 1 second.
[[reqHistoricalData]]
Returns news headline.
reqId: The request's identifier.
hasMore: true
if there are more results available, false
otherwise
[[reqHistoricalNews]]
Returns historical price tick data.
reqId: The request's identifier.
ticks: Array of [[HistoricalTick]] objects.
done: Flag to indicate if all historical tick data has been received.
[[reqHistoricalTicks]]
Returns historical bid/ask tick data.
reqId: The request's identifier.
ticks: Array of [[HistoricalTickBidAsk]] objects.
done: Flag to indicate if all historical tick data has been received.
[[reqHistoricalTicks]]
Returns historical last price tick data.
reqId: The request's identifier.
ticks: Array of [[HistoricalTickLas]] objects.
done: Flag to indicate if all historical tick data has been received.
[[reqHistoricalTicks]]
Receives a comma-separated string with the managed account ids. Occurs automatically on initial API client connection.
accountsList: A comma-separated string with the managed account ids.
[[reqManagedAccts]]
Returns minimum price increment structure for a particular market rule ID. Market rule IDs for an instrument on valid exchanges can be obtained from the contractDetails object for that contract.
marketRuleId: The Market rule IDs.
priceIncrements: Array of price increments.
[[reqMarketRule]]
Called when receives Depth Market Data Descriptions.
depthMktDataDescriptions: Array of [[DepthMktDataDescription]] objects.
[[reqMktDepthExchanges]]
Called when receives News Article.
reqId: The request ID.
articleType: The type of news article (0 - plain text or html, 1 - binary data / pdf)
articleText: The body of article (if articleType == 1, the binary data is encoded using the Base64 scheme)
[[reqNewsArticle]]
Returns array of subscribed API news providers for this user
newsProviders: Array of [NewsProvider]] objects.
[[reqNewsProviders]]
Receives next valid order id. Will be invoked automatically upon successful API client connection, or after call to [[reqIds]].
Important: the next valid order ID is only valid at the time it is received.
orderId: The next order id.
[[reqIds]]
Feeds in currently open orders.
orderId: The order's unique id.
contract: The order's [[Contract]]
order: The currently active [[Order]]
orderState: The order's [[OrderState]]
[[placeOrder]], [[reqAllOpenOrders]], [[reqAutoOpenOrders]]
Notifies the end of the open orders' reception.
Completion callback.
[[placeOrder]], [[reqAllOpenOrders]], [[reqAutoOpenOrders]]
Response to API bind order control message.
Completion callback. orderId: permId
apiClientId: API client id.
apiOrderId: API order id.
[[reqOpenOrders]]
Gives the up-to-date information of an order every time it changes. Often there are duplicate orderStatus messages.
Completion callback. orderId: The order's client id.
status: The current status of the order. Possible values:
filled: Number of filled positions.
remaining: The remnant positions.
avgFillPrice: Average filling price.
permId the order's permId used by the TWS to identify orders.
parentId: parent's id. Used for bracket and auto trailing stop orders.
lastFillPrice: Price at which the last positions were filled.
clientId: API client which submitted the order.
whyHeld: this field is used to identify an order held when TWS is trying to locate shares for a short sell. The value used to indicate this is 'locate'.
mktCapPrice: If an order has been capped, this indicates the current capped price. Requires TWS 967+ and API v973.04+.
Optional
permId: numberOptional
parentId: numberOptional
lastFillPrice: numberOptional
clientId: numberOptional
whyHeld: stringOptional
mktCapPrice: number[[placeOrder]], [[reqAllOpenOrders]], [[reqAutoOpenOrders]]
Receives PnL updates in real time for the daily PnL and the total unrealized PnL for an account.
reqId: The request ID.
dailyPnL: The dailyPnL updates for the account in real time.
unrealizedPnL: The total unrealized PnL updates for the account in real time.
unrealizedPnL: The total realized PnL updates for the account in real time.
Optional
unrealizedPnL: numberOptional
realizedPnL: number[[reqPnL]]
Receives real time updates for single position daily PnL values.
reqId: The request ID.
pos: Current size of the position
dailyPnL: The daily PnL for the position
unrealizedPnL: The total unrealized PnL for the position (since inception) updating in real time.
value: The current market value of the position.
[[reqSinglePnL]]
Provides the portfolio's open positions.
account: The account holding the position.
contract: The position's [[Contract]]
pos: The number of positions held.
avgCost: The average cost of the position.
Optional
avgCost: number[[reqPositions]]
Indicates all the positions have been transmitted.
Completion callback.
[[reqPnL]]
Provides the portfolio's open positions.
reqId: The request ID.
account: The account holding the position.
modelCode: The model code holding the position.
contract: The position's [[Contract]]
pos: The number of positions held.
avgCost: The average cost of the position.
[[reqPositionsMulti]]
Indicates all the positions have been transmitted.
reqId: The request ID.
[[reqPositionsMulti]]
Updates the real time 5 seconds bars.
reqId: The request ID. date: The bar's date and time (Epoch/Unix time). open: The bar's open point. high: The bar's high point. low: The bar's low point. close: The bar's closing point. volume: The bar's traded volume (only returned for TRADES data). WAP: the bar's Weighted Average Price rounded to minimum increment (only available for TRADES). count: the number of trades during the bar's timespan (only available for TRADES).
[[reqRealTimeBars]]
Receives the Financial Advisor's configuration available in the TWS.
faDataType: one of:
faXmlData: The xml-formatted configuration.
[[requestFA]], [[replaceFA]]
Notifies the end of the FA replace.
reqId: The id of request.
text: The message text.
[[requestFA]], [[replaceFA]]
Returns conId and exchange for CFD market data request re-route.
reqId: The id of request.
conId: Contract Id of the underlying instrument which has market data.
exchange: Exchange code of the underlying.
Returns the conId and exchange for an underlying contract when a request is made for level 2 data for an instrument which does not have data in IB's database. For example stock CFDs and index CFDs.
reqId: The id of request.
conId: Contract Id of the underlying instrument which has market data.
exchange: Exchange code of the underlying.
Provides the data resulting from the market scanner request.
reqId: The id of request.
rank: The ranking within the response of this bar.
contractDetails: The data [[ContractDetails].
distance: variable, according to query.
benchmark: variable, according to query.
projection: variable, according to query.
legStr: Describes the combo legs when the scanner is returning EFP.
Optional
legsStr: string[[reqScannerSubscription]]
Indicates the scanner data reception has terminated.
reqId: The id of request.
[[reqScannerSubscription]]
Provides the xml-formatted parameters available from TWS market scanners (not all available in API).
xml: The xml-formatted string with the available parameters.
[[reqScannerParameters]]
Provides the option chain for an underlying on an exchange specified in reqSecDefOptParams. There will be multiple callbacks to securityDefinitionOptionParameter if multiple exchanges are specified in reqSecDefOptParams.
reqId: The id of request.
underlyingConId: The conID of the underlying security.
tradingClass: The option trading class.
multiplier: The option multiplier.
expirations: An array of the expiries for the options of this underlying on this exchange.
strikes: An array of of the possible strikes for options of this underlying on this exchange.
[[reqSecDefOptParams]]
Called when all callbacks to securityDefinitionOptionParameter are complete.
reqId: The id of request.
[[reqSecDefOptParams]]
Bit number to exchange + exchange abbreviation dictionary.
reqId: The id of request.
[[reqSmartComponents]]
Called when receives Soft Dollar Tier configuration information.
reqId: The id of request.
tiers: An array of [[SoftDollarTier]] objects that contains all Soft Dollar Tiers information.
[[reqSoftDollarTiers]]
Provides an array of sample contract descriptions.
reqId: The id of request.
tiers: An array of [[ContractDescription]] objects.
[[reqMatchingSymbols]]
Provides "Last" or "AllLast" tick-by-tick real-time tick.
reqId: The id of request.
tickType: The tick-by-tick real-time tick type: "Last" or "AllLast".
time: The tick-by-tick real-time tick timestamp.
price: The tick-by-tick real-time tick last price.
size: The tick-by-tick real-time tick last size.
tickAttribLast: The tick-by-tick real-time last tick attribs (bit 0 - past limit, bit 1 - unreported).
exchange: The tick-by-tick real-time tick exchange.
specialConditions: The tick-by-tick real-time tick special conditions.
[[reqTickByTickData]]
Provides "BidAsk" tick-by-tick real-time tick.
reqId: The id of request.
time: The tick-by-tick real-time tick timestamp.
bidPrice: The tick-by-tick real-time tick bid price.
askPrice: The tick-by-tick real-time tick ask price.
bidSize: The tick-by-tick real-time tick bid size.
askSize: The tick-by-tick real-time tick ask size.
tickAttribLast: The tick-by-tick real-time bid/ask tick attribs (bit 0 - bid past low, bit 1 - ask past high).
[[reqTickByTickData]]
Provides "MidPoint" tick-by-tick real-time tick.
reqId: The id of request.
time: The tick-by-tick real-time tick timestamp.
midPoint: The tick-by-tick real-time tick mid point.
[[reqTickByTickData]]
Exchange for Physicals.
reqId: The request's identifier.
tickType: The type of tick being received.
basisPoints: Annualized basis points, which is representative of the financing rate that can be directly compared to broker rates.
formattedBasisPoints: Annualized basis points as a formatted string that depicts them in percentage form.
impliedFuture: The implied Futures price.
holdDays: The number of hold days until the lastTradeDate of the EFP.
futureLastTradeDate: The expiration date of the single stock future.
dividendImpact: The dividend impact upon the annualized basis points interest rate.
dividendsToLastTradeDate: The dividends expected until the expiration of the single stock future.
Provides a market data generic tick.
reqId: The id of request.
field: The type of tick being received.
value: The tick value.
[[reqTickByTickData]]
Provides a news headline tick.
reqId: The id of request.
field: The type of tick being received.
value: The tick value.
[[reqTickByTickData]]
Provides option specific market data. This method is called when the market in an option or its underlier moves. TWS option model volatilities, prices, and deltas, along with the present value of dividends expected on that options underlier are received.
reqId: The id of request.
field: Specifies the type of option computation. Pass the field value into [[TickType.getField]] to retrieve the field description. For example, a field value of 13 will map to modelOptComp, etc. 10 = Bid 11 = Ask 12 = Last
impliedVolatility: The implied volatility calculated by the TWS option modeler, using the specified tick type value.
delta: The option delta value.
value: The tick value.
optPrice: The option price.
pvDividend: The present value of dividends expected on the option's underlying.
gamma:The option gamma value.
vega: The option vega value.
theta: The option theta value.
undPrice: The price of the underlying.
Optional
impliedVolatility: numberOptional
delta: numberOptional
optPrice: numberOptional
pvDividend: numberOptional
gamma: numberOptional
vega: numberOptional
theta: numberOptional
undPrice: number[[reqMktData]]
Market data tick price callback. Handles all price related ticks. Every tickPrice callback is followed by a tickSize. A tickPrice value of -1 or 0 followed by a tickSize of 0 indicates there is no data for this field currently available, whereas a tickPrice with a positive tickSize indicates an active quote of 0 (typically for a combo contract).
reqId: The id of request.
field: The type of the price being received.
price: The actual price.
value: The tick value.
attribs: An [[TickAttrib]] object that contains price attributes.
Optional
attribs: unknown[[reqMktData]]
A tick with BOO exchange and snapshot permissions.
reqId: The id of request.
[[reqMktData]]
Market data tick size callback. Handles all size-related ticks.
reqId: The id of request.
field: The type of size being received (i.e. bid size)
size: The actual size.
Optional
field: IBApiTickTypeOptional
value: number[[reqMktData]]
Market data callback. Every tickPrice is followed by a tickSize. There are also independent tickSize callbacks anytime the tickSize changes, and so there will be duplicate tickSize messages following a tickPrice.
reqId: The id of request.
field: The type of size being received (i.e. bid size)
value: The tick value.
[[reqMktData]]
Receives the last time on which the account was updated.
timestamp: The last update system time.
[[reqMktData]]
Receives the subscribed account's information. Only one account can be subscribed at a time. After the initial callback to updateAccountValue, callbacks only occur for values which have changed. This occurs at the time of a position change, or every 3 minutes at most. This frequency cannot be adjusted.
key: The value being updated. Possible values:
[[reqAccountUpdates]]
Receives the subscribed account's portfolio.
This function will receive only the portfolio of the subscribed account.
If the portfolios of all managed accounts are needed, refer to [[reqPosition]].
After the initial callback to updatePortfolio
, callbacks only occur for positions which have changed.
contract: The Contract for which a position is held.
position: The number of positions held.
marketPrice: Instrument's unitary price.
marketValue: Total market value of the instrument.
averageCost: Average acquiring price of the instrument.
unrealizedPNL: Unrealized Profit/Loss.
realizedPNL: Realized Profit/Loss.
accountName: The account name.
Optional
averageCost: numberOptional
unrealizedPNL: numberOptional
realizedPNL: numberOptional
accountName: stringReturns the order book.
reqId: The request's identifier.
position: The order book's row being updated.
operation: How to refresh the row:
side: 0 for ask, 1 for bid.
price: The order's price.
size: The order's size.
[[reqMktDepth]]
Returns the order book (level 2).
reqId: The request's identifier.
position: The order book's row being updated.
marketMaker: The exchange holding the order if isSmartDepth is true
, otherwise the MPID of the market maker.
operation: How to refresh the row:
side: 0 for ask, 1 for bid.
price: The order's price.
size: The order's size.
isSmartDepth: A flag indicating if this is smart depth response (aggregate data from multiple exchanges, v974+)
Optional
isSmartDepth: boolean[[reqMktDepth]]
Provides IB's bulletins.
msgId: The bulletin's identifier.
msgType: one of:
message: The message.
origExchange: The exchange where the message comes from.
Notifies when new user info has arrived.
whiteBrandingId: The user's info
[[reqUserInfo]]
Places or modifies an order.
The order's unique identifier. Use a sequential id starting with the id received at the nextValidId method. If a new order is placed with an order ID less than or equal to the order ID of a previous order an error will occur.
The order's [[Contract]].
The [[Order]] object.
[[reqAllOpenOrders]], [[reqAutoOpenOrders]], [[reqOpenOrders]], [[cancelOrder]], [[reqGlobalCancel]]
Remove the listeners of a given event.
Optional
fn: ((...args) => void)Rest
...args: any[]Optional
context: anyOptional
once: booleanReplaces Financial Advisor's settings A Financial Advisor can define three different configurations:
The configuration to change.
Zhe xml-formatted configuration string.
Requests a specific account's summary. This method will subscribe to the account summary as presented in the TWS' Account Summary tab. The data is emitted as accountSummary event.
https://www.interactivebrokers.com/en/software/tws/accountwindowtop.htm
The unique request identifier.
Set to "All" to return account summary data for all accounts, or set to a specific Advisor Account Group name that has already been created in TWS Global Configuration.
A comma separated list with the desired tags:
[[cancelAccountSummary]]
Subscribes to a specific account's information and portfolio. Through this method, a single account's subscription can be started/stopped. As a result from the subscription, the account's information, portfolio and last update time will be emitted as updateAccountValue, updateAccountPortfolio, updateAccountTime event respectively.
All account values and positions will be returned initially, and then there will only be updates when there is a change in a position, or to an account value every 3 minutes if it has changed.
Only one account can be subscribed at a time.
A second subscription request for another account when the previous one is still active will cause the first one to be canceled in favour of the second one. Consider user reqPositions if you want to retrieve all your accounts' portfolios directly.
Set to true to start the subscription and to false to stop it.
The account id (i.e. U123456) for which the information is requested.
[[reqPositions]]
Requests account updates for account and/or model.
Identifier to label the request.
Account values can be requested for a particular account
Values can also be requested for a model
returns light-weight request; only currency positions as opposed to account values and currency positions.
[[cancelAccountUpdatesMulti]]
Requests all current open orders in associated accounts at the current moment. The existing orders will be received via the openOrder and orderStatus events.
Open orders are returned once; this function does not initiate a subscription.
[[reqAutoOpenOrders]], [[reqOpenOrders]]
Requests status updates about future orders placed from TWS. Can only be used with client ID 0.
if set to true
, the newly created orders will be assigned an API order ID and implicitly
associated with this client. If set to `false, future orders will not be.
[[reqAllOpenOrders]], [[reqOpenOrders]], [[cancelOrder]], [[reqGlobalCancel]]
Requests contract information. This method will provide all the contracts matching the contract provided.
It can also be used to retrieve complete options and futures chains. Though it is now (in API version > 9.72.12) advised to use reqSecDefOptParams for that purpose.
This information will be emitted as contractDetails event.
The unique request identifier.
The contract used as sample to query the available contracts.
Requests current day's (since midnight) executions matching the filter. Only the current day's executions can be retrieved. Along with the executions, the CommissionReport will also be returned.
The execution details will be emitted as execDetails event.
The request's unique identifier.
The filter criteria used to determine which execution reports are returned.
Requests the contract's fundamental data. Fundamental data is emitted as fundamentalData event.
The request's unique identifier.
The contract's description for which the data will be returned.
there are three available report types:
Returns the timestamp of earliest available historical data for a contract and data type.
An identifier for the request.
[[Contract]] object for which head timestamp is being requested.
Type of data for head timestamp - "BID", "ASK", "TRADES", etc
Use regular trading hours only, true
for yes or false
for no.
Set to 1 to obtain the bars' time as yyyyMMdd HH:mm:ss, set to 2 to obtain it like system time format in seconds.
Returns data histogram of specified contract.
An identifier for the request.
[[Contract]] object for which histogram is being requested
Use regular trading hours only, true
for yes or false
for no.
Period of which data is being requested
Unit of the period of which data is being requested
Requests contracts' historical data. When requesting historical data, a finishing time and date is required along
with a duration string. For example, having:
- endDateTime: 20130701 23:59:59 GMT```
- durationStr: 3 ```
will return three days of data counting backwards from July 1st 2013 at 23:59:59 GMT resulting in all the
available bars of the last three days until the date and time specified.
It is possible to specify a timezone optionally.
The resulting bars will be emitted as historicalData event.
@param reqId The request's unique identifier. @param contract The contract for which we want to retrieve the data. @param endDateTime Request's ending time with format yyyyMMdd HH:mm:ss {TMZ} @param durationStr The amount of time for which the data needs to be retrieved (number space unit). Note: min duration is "30 S", available units:
true
to received continuous updates on most recent bar data. If true
, and
endDateTime cannot be specified.Requests historical news headlines.
ID of the request.
Contract id of ticker.
A '+'-separated list of provider codes .
Marks the (exclusive) start of the date range. The format is yyyy-MM-dd HH:mm:ss.0
Marks the (inclusive) end of the date range. The format is yyyy-MM-dd HH:mm:ss.0
The maximum number of headlines to fetch (1 - 300).
Requests historical Time&Sales data for an instrument.
ID of the request.
[[Contract]] object that is subject of query
"20170701 12:01:00". Uses TWS timezone specified at login.
"20170701 13:01:00". In TWS timezone. Exactly one of start time and end time has to be defined.
Number of distinct data points. Max currently 1000 per request.
(Bid_Ask, Midpoint, Trades) Type of data requested.
Data from regular trading hours (1), or all available hours (0)
A filter only used when the source price is Bid_Ask
Switches data type returned from reqMktData request to "frozen", "delayed" or "delayed-frozen" market data. Requires TWS/IBG v963+.
The API can receive frozen market data from Trader Workstation. Frozen market data is the last data recorded in our system. During normal trading hours, the API receives real-time market data. Invoking this function with argument 2 requests a switch to frozen data immediately or after the close. When the market reopens, the market data type will automatically switch back to real time if available.
By default only real-time (1) market data is enabled.
Requests details about a given market rule. The market rule for an instrument on a particular exchange provides details about how the minimum price increment changes with price. A list of market rule ids can be obtained by invoking reqContractDetails on a particular contract. The returned market rule ID list will provide the market rule ID for the instrument in the correspond valid exchange list in contractDetails.
The id of market rule.
Requests real time market data. Returns market data for an instrument either in real time or 10-15 minutes delayed (depending on the market data type specified).
The request's identifier.
The [[Contract]] for which the data is being requested
comma separated ids of the available generic ticks:
For users with corresponding real time market data subscriptions.
A true
value will return a one-time snapshot, while a false
value will provide streaming data.
Snapshot for US stocks requests NBBO snapshots for users which have "US Securities Snapshot Bundle" subscription but not corresponding Network A, B, or C subscription necessary for streaming * market data. One-time snapshot of current market price that will incur a fee of 1 cent to the account per snapshot.
[[cancelMktData]]
Requests the contract's market depth (order book).
This request must be direct-routed to an exchange and not smart-routed.
The number of simultaneous market depth requests allowed in an account is calculated based on a formula that looks at an accounts equity, commissions, and quote booster packs.
The request's identifier.
The [[Contract]] for which the depth is being requested.
The number of rows on each side of the order book.
Flag indicates that this is smart depth request.
Optional
mktDepthOptions: TagValue[]TODO document
[[cancelMktDepth]]
Requests news article body given articleId.
ID of the request.
Short code indicating news provider, e.g. FLY
ID of the specific article.
Creates subscription for real time daily PnL and unrealized PnL updates.
ID of the request.
Account for which to receive PnL updates.
Optional
modelCode: stringSpecify to request PnL updates for a specific model.
Requests real time updates for daily PnL of individual positions.
ID of the request.
Account in which position exists.
Model in which position exists.
Contract ID (conId) of contract to receive daily PnL updates for. Note: does not return message if invalid conId is entered.
Requests position subscription for account and/or model. Initially all positions are returned and then updates are returned for any position changes in real time.
Request's identifier.
If an account Id is provided, only the account's positions belonging to the specified model will be delivered.
The code of the model's positions we are interested in.
[[cancelPositionsMulti]]
Requests real time bars.
Currently, only 5 seconds bars are provided.
This request is subject to the same pacing as any historical data request: no more than 60 API queries in more than 600 seconds. Real time bars subscriptions are also included in the calculation of the number of Level 1 market data subscriptions allowed in an account.
The request's unique identifier.
The [[Contract]] for which the depth is being requested
currently being ignored
the nature of the data being retrieved:
Set to false
to obtain the data which was also generated ourside of the Regular Trading Hours.
Set to true
to obtain only the RTH data
[[cancelRealTimeBars]]
Starts a subscription to market scan results based on the provided parameters.
The request's identifier.
Summary of the scanner subscription including its filters.
TODO document
TODO document
[[reqScannerParameters]]
Requests security definition option parameters for viewing a contract's option chain.
The request's identifier.
Underlying symbol name.
The exchange on which the returned options are trading. Can be set to the empty string "" for all exchanges.
The type of the underlying security, i.e. STK
the contract ID of the underlying security
Requests tick-by-tick data.
Unique identifier of the request.
The [[Contract]] for which tick-by-tick data is requested.
tick-by-tick data type: "Last", "AllLast", "BidAsk" or "MidPoint".
number of ticks.
ignore size flag.
Requests event data from the wSH calendar.
The unique request identifier.
[[reqCancelWshEventData]]
Requests the FA configuration A Financial Advisor can define three different configurations:
More information at https://www.interactivebrokers.com/en/?f=%2Fen%2Fsoftware%2Fpdfhighlights%2FPDF-AdvisorAllocations.php%3Fib_entity%3Dllc
The configuration to change. Set to 1, 2 or 3 as defined above.
Updates the contract displayed in a TWS Window Group.
The ID chosen for this request.
An encoded value designating a unique IB contract. Possible values include:
Generated using TypeDoc
Typescript implementation of the Interactive Brokers TWS (or IB Gateway) API.
Refer to the official Workstation API documentation for details.