|
|
This documentation is now deprecated. Please switch to the IBKR Campus for up-to-date information regarding IBKR's API solutions. |
This interface's methods are used by the TWS/Gateway to communicate with the API client. Every API client application needs to implement this interface in order to handle all the events generated by the TWS/Gateway. Almost every EClientSocket method call will result in at least one event delivered here. More...
Public Member Functions | |
void | error (Exception e) |
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 EWrapper's implementing class. More... | |
void | error (string str) |
void | error (int id, int errorCode, string errorMsg, string advancedOrderRejectJson) |
Errors sent by the TWS are received here. More... | |
void | currentTime (long time) |
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. More... | |
void | tickPrice (int tickerId, int field, double price, TickAttrib attribs) |
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). More... | |
void | tickSize (int tickerId, int field, decimal size) |
Market data tick size callback. Handles all size-related ticks. More... | |
void | tickString (int tickerId, int field, string value) |
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. More... | |
void | tickGeneric (int tickerId, int field, double value) |
Market data callback. More... | |
void | tickEFP (int tickerId, int tickType, double basisPoints, string formattedBasisPoints, double impliedFuture, int holdDays, string futureLastTradeDate, double dividendImpact, double dividendsToLastTradeDate) |
Exchange for Physicals. More... | |
void | deltaNeutralValidation (int reqId, DeltaNeutralContract deltaNeutralContract) |
| |
void | tickOptionComputation (int tickerId, int field, int tickAttrib, double impliedVolatility, double delta, double optPrice, double pvDividend, double gamma, double vega, double theta, double undPrice) |
Receive's option specific market data. This method is called when the market in an option or its underlier moves. TWS’s option model volatilities, prices, and deltas, along with the present value of dividends expected on that options underlier are received. More... | |
void | tickSnapshotEnd (int tickerId) |
When requesting market data snapshots, this market will indicate the snapshot reception is finished. Expected to occur 11 seconds after beginning of request. | |
void | nextValidId (int orderId) |
Receives next valid order id. Will be invoked automatically upon successfull API client connection, or after call to EClient::reqIds Important: the next valid order ID is only valid at the time it is received. More... | |
void | managedAccounts (string accountsList) |
Receives a comma-separated string with the managed account ids. Occurs automatically on initial API client connection. More... | |
void | connectionClosed () |
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. More... | |
void | accountSummary (int reqId, string account, string tag, string value, string currency) |
Receives the account information. This method will receive the account information just as it appears in the TWS' Account Summary Window. More... | |
void | accountSummaryEnd (int reqId) |
notifies when all the accounts' information has ben received. Requires TWS 967+ to receive accountSummaryEnd in linked account structures. More... | |
void | bondContractDetails (int reqId, ContractDetails contract) |
Delivers the Bond contract data after this has been requested via reqContractDetails. More... | |
void | updateAccountValue (string key, string value, string currency, string accountName) |
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. More... | |
void | updatePortfolio (Contract contract, decimal position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, string accountName) |
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 EClientSocket::reqPosition After the initial callback to updatePortfolio, callbacks only occur for positions which have changed. More... | |
void | updateAccountTime (string timestamp) |
Receives the last time on which the account was updated. More... | |
void | accountDownloadEnd (string account) |
Notifies when all the account's information has finished. More... | |
void | orderStatus (int orderId, string status, decimal filled, decimal remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, string whyHeld, double mktCapPrice) |
Gives the up-to-date information of an order every time it changes. Often there are duplicate orderStatus messages. More... | |
void | openOrder (int orderId, Contract contract, Order order, OrderState orderState) |
Feeds in currently open orders. More... | |
void | openOrderEnd () |
Notifies the end of the open orders' reception. More... | |
void | contractDetails (int reqId, ContractDetails contractDetails) |
receives the full contract's definitions This method will return all contracts matching the requested via EClientSocket::reqContractDetails. For example, one can obtain the whole option chain with it. More... | |
void | contractDetailsEnd (int reqId) |
After all contracts matching the request were returned, this method will mark the end of their reception. More... | |
void | execDetails (int reqId, Contract contract, Execution execution) |
Provides the executions which happened in the last 24 hours. More... | |
void | execDetailsEnd (int reqId) |
indicates the end of the Execution reception. More... | |
void | commissionReport (CommissionReport commissionReport) |
provides the CommissionReport of an Execution More... | |
void | fundamentalData (int reqId, string data) |
returns fundamental data More... | |
void | historicalData (int reqId, Bar bar) |
returns the requested historical data bars More... | |
void | historicalDataUpdate (int reqId, Bar bar) |
Receives bars in real time if keepUpToDate is set as 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. More... | |
void | historicalDataEnd (int reqId, string start, string end) |
Marks the ending of the historical bars reception. | |
void | marketDataType (int reqId, int marketDataType) |
Returns the market data type (real-time, frozen, delayed, delayed-frozen) of ticker sent by EClientSocket::reqMktData when TWS switches from real-time to frozen and back and from delayed to delayed-frozen and back. More... | |
void | updateMktDepth (int tickerId, int position, int operation, int side, double price, decimal size) |
Returns the order book. More... | |
void | updateMktDepthL2 (int tickerId, int position, string marketMaker, int operation, int side, double price, decimal size, bool isSmartDepth) |
Returns the order book. More... | |
void | updateNewsBulletin (int msgId, int msgType, string message, string origExchange) |
provides IB's bulletins More... | |
void | position (string account, Contract contract, decimal pos, double avgCost) |
provides the portfolio's open positions. More... | |
void | positionEnd () |
Indicates all the positions have been transmitted. More... | |
void | realtimeBar (int reqId, long date, double open, double high, double low, double close, decimal volume, decimal WAP, int count) |
updates the real time 5 seconds bars More... | |
void | scannerParameters (string xml) |
provides the xml-formatted parameters available from TWS market scanners (not all available in API). More... | |
void | scannerData (int reqId, int rank, ContractDetails contractDetails, string distance, string benchmark, string projection, string legsStr) |
provides the data resulting from the market scanner request. More... | |
void | scannerDataEnd (int reqId) |
Indicates the scanner data reception has terminated. More... | |
void | receiveFA (int faDataType, string faXmlData) |
receives the Financial Advisor's configuration available in the TWS More... | |
void | verifyMessageAPI (string apiData) |
Not generally available. | |
void | verifyCompleted (bool isSuccessful, string errorText) |
Not generally available. | |
void | verifyAndAuthMessageAPI (string apiData, string xyzChallenge) |
Not generally available. | |
void | verifyAndAuthCompleted (bool isSuccessful, string errorText) |
Not generally available. | |
void | displayGroupList (int reqId, string groups) |
a one-time response to querying the display groups. More... | |
void | displayGroupUpdated (int reqId, string contractInfo) |
call triggered once after receiving the subscription request, and will be sent again if the selected contract in the subscribed * display group has changed. More... | |
void | connectAck () |
callback initially acknowledging connection attempt connection handshake not complete until nextValidID is received | |
void | positionMulti (int requestId, string account, string modelCode, Contract contract, decimal pos, double avgCost) |
provides the portfolio's open positions. More... | |
void | positionMultiEnd (int requestId) |
Indicates all the positions have been transmitted. More... | |
void | accountUpdateMulti (int requestId, string account, string modelCode, string key, string value, string currency) |
provides the account updates. More... | |
void | accountUpdateMultiEnd (int requestId) |
Indicates all the account updates have been transmitted. More... | |
void | securityDefinitionOptionParameter (int reqId, string exchange, int underlyingConId, string tradingClass, string multiplier, HashSet< string > expirations, HashSet< double > strikes) |
returns 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 More... | |
void | securityDefinitionOptionParameterEnd (int reqId) |
called when all callbacks to securityDefinitionOptionParameter are complete More... | |
void | softDollarTiers (int reqId, SoftDollarTier[] tiers) |
called when receives Soft Dollar Tier configuration information More... | |
void | familyCodes (FamilyCode[] familyCodes) |
returns array of family codes More... | |
void | symbolSamples (int reqId, ContractDescription[] contractDescriptions) |
returns array of sample contract descriptions More... | |
void | mktDepthExchanges (DepthMktDataDescription[] depthMktDataDescriptions) |
called when receives Depth Market Data Descriptions More... | |
void | tickNews (int tickerId, long timeStamp, string providerCode, string articleId, string headline, string extraData) |
ticks with news headline More... | |
void | smartComponents (int reqId, Dictionary< int, KeyValuePair< string, char >> theMap) |
bit number to exchange + exchange abbreviation dictionary More... | |
void | tickReqParams (int tickerId, double minTick, string bboExchange, int snapshotPermissions) |
tick with BOO exchange and snapshot permissions More... | |
void | newsProviders (NewsProvider[] newsProviders) |
returns array of subscribed API news providers for this user More... | |
void | newsArticle (int requestId, int articleType, string articleText) |
called when receives News Article More... | |
void | historicalNews (int requestId, string time, string providerCode, string articleId, string headline) |
returns news headline More... | |
void | historicalNewsEnd (int requestId, bool hasMore) |
returns news headlines end marker More... | |
void | headTimestamp (int reqId, string headTimestamp) |
| |
void | histogramData (int reqId, HistogramEntry[] data) |
returns data histogram More... | |
void | rerouteMktDataReq (int reqId, int conId, string exchange) |
| |
void | rerouteMktDepthReq (int reqId, int conId, string exchange) |
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. More... | |
void | marketRule (int marketRuleId, PriceIncrement[] priceIncrements) |
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 More... | |
void | pnl (int reqId, double dailyPnL, double unrealizedPnL, double realizedPnL) |
receives PnL updates in real time for the daily PnL and the total unrealized PnL for an account More... | |
void | pnlSingle (int reqId, decimal pos, double dailyPnL, double unrealizedPnL, double realizedPnL, double value) |
receives real time updates for single position daily PnL values More... | |
void | historicalTicks (int reqId, HistoricalTick[] ticks, bool done) |
void | historicalTicksBidAsk (int reqId, HistoricalTickBidAsk[] ticks, bool done) |
void | historicalTicksLast (int reqId, HistoricalTickLast[] ticks, bool done) |
void | tickByTickAllLast (int reqId, int tickType, long time, double price, decimal size, TickAttribLast tickAttribLast, string exchange, string specialConditions) |
returns "Last" or "AllLast" tick-by-tick real-time tick More... | |
void | tickByTickBidAsk (int reqId, long time, double bidPrice, double askPrice, decimal bidSize, decimal askSize, TickAttribBidAsk tickAttribBidAsk) |
returns "BidAsk" tick-by-tick real-time tick More... | |
void | tickByTickMidPoint (int reqId, long time, double midPoint) |
returns "MidPoint" tick-by-tick real-time tick More... | |
void | orderBound (long orderId, int apiClientId, int apiOrderId) |
response to API bind order control message More... | |
void | completedOrder (Contract contract, Order order, OrderState orderState) |
Feeds in completed orders. More... | |
void | completedOrdersEnd () |
Notifies the end of the completed orders' reception. More... | |
void | replaceFAEnd (int reqId, string text) |
notifies the end of the FA replace. More... | |
void | wshMetaData (int reqId, string dataJson) |
returns meta data from the WSH calendar More... | |
void | wshEventData (int reqId, string dataJson) |
returns calendar events from the WSH More... | |
void | historicalSchedule (int reqId, string startDateTime, string endDateTime, string timeZone, HistoricalSession[] sessions) |
returns historical schedule More... | |
void | userInfo (int reqId, string whiteBrandingId) |
returns user info More... | |
This interface's methods are used by the TWS/Gateway to communicate with the API client. Every API client application needs to implement this interface in order to handle all the events generated by the TWS/Gateway. Almost every EClientSocket method call will result in at least one event delivered here.
void accountDownloadEnd | ( | string | account) |
Notifies when all the account's information has finished.
account | the account's id |
void accountSummary | ( | int | reqId, |
string | account, | ||
string | tag, | ||
string | value, | ||
string | currency | ||
) |
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.
|
value | the account's attribute's value. |
currency | the currency on which the value is expressed. |
void accountSummaryEnd | ( | int | reqId) |
notifies when all the accounts' information has ben received. Requires TWS 967+ to receive accountSummaryEnd in linked account structures.
reqId | the request's identifier. |
void accountUpdateMulti | ( | int | requestId, |
string | account, | ||
string | modelCode, | ||
string | key, | ||
string | value, | ||
string | currency | ||
) |
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 |
void accountUpdateMultiEnd | ( | int | requestId) |
Indicates all the account updates have been transmitted.
void bondContractDetails | ( | int | reqId, |
ContractDetails | contract | ||
) |
Delivers the Bond contract data after this has been requested via reqContractDetails.
reqId | the request's identifier |
contract | the bond contract's information. |
void commissionReport | ( | CommissionReport | commissionReport) |
provides the CommissionReport of an Execution
void completedOrder | ( | Contract | contract, |
Order | order, | ||
OrderState | orderState | ||
) |
Feeds in completed orders.
contract | the order's Contract. |
order | the completed Order. |
orderState | the order's OrderState |
void completedOrdersEnd | ( | ) |
Notifies the end of the completed orders' reception.
void connectionClosed | ( | ) |
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.
void contractDetails | ( | int | reqId, |
ContractDetails | contractDetails | ||
) |
receives the full contract's definitions This method will return all contracts matching the requested via EClientSocket::reqContractDetails. For example, one can obtain the whole option chain with it.
reqId | the unique request identifier |
contractDetails | the instrument's complete definition. |
void contractDetailsEnd | ( | int | reqId) |
After all contracts matching the request were returned, this method will mark the end of their reception.
reqId | the request's identifier |
void currentTime | ( | long | time) |
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.
void deltaNeutralValidation | ( | int | reqId, |
DeltaNeutralContract | deltaNeutralContract | ||
) |
reqId | the request's identifier. |
deltaNeutralContract | Delta-Neutral Contract |
void displayGroupList | ( | int | reqId, |
string | groups | ||
) |
a one-time response to querying the display groups.
reqId | the ID of the request |
It | returns a list of integers representing visible Group ID separated by the "|" character, and sorted by most used group first. |
void displayGroupUpdated | ( | int | reqId, |
string | contractInfo | ||
) |
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 |
void error | ( | Exception | e) |
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 EWrapper's implementing class.
e | the thrown exception. |
void error | ( | string | str) |
str | The error message received. |
void error | ( | int | id, |
int | errorCode, | ||
string | errorMsg, | ||
string | advancedOrderRejectJson | ||
) |
Errors sent by the TWS are received here.
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. |
advancedOrderRejectJson | advanced order reject description in json format. |
void execDetailsEnd | ( | int | reqId) |
indicates the end of the Execution reception.
reqId | the request's identifier |
void familyCodes | ( | FamilyCode[] | familyCodes) |
void fundamentalData | ( | int | reqId, |
string | data | ||
) |
returns fundamental data
reqId | the request's identifier |
data | xml-formatted fundamental data |
void headTimestamp | ( | int | reqId, |
string | headTimestamp | ||
) |
requestId | |
headTimestamp | - string identifying earliest data date |
void histogramData | ( | int | reqId, |
HistogramEntry[] | data | ||
) |
returns data histogram
requestId | |
data | - returned Tuple of histogram data, number of trades at specified price level |
void historicalData | ( | int | reqId, |
Bar | bar | ||
) |
returns the requested historical data bars
reqId | the request's identifier |
bar | the OHLC historical data Bar. The time zone of the bar is the time zone chosen on the TWS login screen. Smallest bar size is 1 second. |
void historicalDataUpdate | ( | int | reqId, |
Bar | bar | ||
) |
Receives bars in real time if keepUpToDate is set as 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 requests identifier |
bar | the OHLC historical data Bar. The time zone of the bar is the time zone chosen on the TWS login screen. Smallest bar size is 1 second. |
void historicalNews | ( | int | requestId, |
string | time, | ||
string | providerCode, | ||
string | articleId, | ||
string | headline | ||
) |
returns news headline
requestId | |
time | |
providerCode | |
articleId | |
headline |
void historicalNewsEnd | ( | int | requestId, |
bool | hasMore | ||
) |
returns news headlines end marker
requestId | |
hasMore | - indicates whether there are more results available, false otherwise |
void historicalSchedule | ( | int | reqId, |
string | startDateTime, | ||
string | endDateTime, | ||
string | timeZone, | ||
HistoricalSession[] | sessions | ||
) |
returns historical schedule
reqId | the id of request |
startDateTime | |
endDateTime | |
timeZone | |
sessions |
void historicalTicks | ( | int | reqId, |
HistoricalTick[] | ticks, | ||
bool | done | ||
) |
reqId | |
ticks | list of HistoricalTick data |
done | flag to indicate if all historical tick data has been received |
void historicalTicksBidAsk | ( | int | reqId, |
HistoricalTickBidAsk[] | ticks, | ||
bool | done | ||
) |
reqId | |
ticks | list of HistoricalBidAsk data |
done | flag to indicate if all historical tick data has been received |
void historicalTicksLast | ( | int | reqId, |
HistoricalTickLast[] | ticks, | ||
bool | done | ||
) |
reqId | |
ticks | list of HistoricalTickLast data |
done | flag to indicate if all historical tick data has been received |
void managedAccounts | ( | string | accountsList) |
Receives a comma-separated string with the managed account ids. Occurs automatically on initial API client connection.
void marketDataType | ( | int | reqId, |
int | marketDataType | ||
) |
Returns the market data type (real-time, frozen, delayed, delayed-frozen) of ticker sent by EClientSocket::reqMktData when TWS switches from real-time to frozen and back and from delayed to delayed-frozen and back.
reqId | the id of ticker sent in reqMktData |
marketDataType | means that now API starts to tick with the following market data: 1 for real-time, 2 for frozen, 3 for delayed, 4 for delayed-frozen |
void marketRule | ( | int | marketRuleId, |
PriceIncrement[] | priceIncrements | ||
) |
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 | |
PriceIncrement[] |
void mktDepthExchanges | ( | DepthMktDataDescription[] | depthMktDataDescriptions) |
called when receives Depth Market Data Descriptions
descriptions | Stores a list of DepthMktDataDescription |
void newsArticle | ( | int | requestId, |
int | articleType, | ||
string | articleText | ||
) |
called when receives News Article
requestId | The request ID used in the call to EClient::reqNewsArticle |
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) |
void newsProviders | ( | NewsProvider[] | newsProviders) |
returns array of subscribed API news providers for this user
NewsProvider[] |
void nextValidId | ( | int | orderId) |
Receives next valid order id. Will be invoked automatically upon successfull API client connection, or after call to EClient::reqIds Important: the next valid order ID is only valid at the time it is received.
orderId | the next order id |
void openOrder | ( | int | orderId, |
Contract | contract, | ||
Order | order, | ||
OrderState | orderState | ||
) |
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 |
void openOrderEnd | ( | ) |
Notifies the end of the open orders' reception.
void orderBound | ( | long | orderId, |
int | apiClientId, | ||
int | apiOrderId | ||
) |
response to API bind order control message
orderId | - permId |
apiClientId | - API client id |
apiOrderId | - API order id |
void orderStatus | ( | int | orderId, |
string | status, | ||
decimal | filled, | ||
decimal | remaining, | ||
double | avgFillPrice, | ||
int | permId, | ||
int | parentId, | ||
double | lastFillPrice, | ||
int | clientId, | ||
string | whyHeld, | ||
double | mktCapPrice | ||
) |
Gives the up-to-date information of an order every time it changes. Often there are duplicate orderStatus messages.
orderId | the order's client id. |
status | the current status of the order. Possible values: PendingSubmit - indicates that you have transmitted the order, but have not yet received confirmation that it has been accepted by the order destination. PendingCancel - indicates that you have sent a request to cancel the order but have not yet received cancel confirmation from the order destination. At this point, your order is not confirmed canceled. It is not guaranteed that the cancellation will be successful. PreSubmitted - indicates that a simulated order type has been accepted by the IB system and that this order has yet to be elected. The order is held in the IB system until the election criteria are met. At that time the order is transmitted to the order destination as specified . Submitted - indicates that your order has been accepted by the system. ApiCancelled - after an order has been submitted and before it has been acknowledged, an API client client can request its cancelation, producing this state. Cancelled - indicates that the balance of your order has been confirmed canceled by the IB system. This could occur unexpectedly when IB or the destination has rejected your order. Filled - indicates that the order has been completely filled. Market orders executions will not always trigger a Filled status. Inactive - indicates that the order was received by the system but is no longer active because it was rejected or canceled. |
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+. Python API specifically requires API v973.06+. |
void pnl | ( | int | reqId, |
double | dailyPnL, | ||
double | unrealizedPnL, | ||
double | realizedPnL | ||
) |
receives PnL updates in real time for the daily PnL and the total unrealized PnL for an account
reqId | |
dailyPnL | dailyPnL updates for the account in real time |
unrealizedPnL | total unRealized PnL updates for the account in real time |
void pnlSingle | ( | int | reqId, |
decimal | pos, | ||
double | dailyPnL, | ||
double | unrealizedPnL, | ||
double | realizedPnL, | ||
double | value | ||
) |
receives real time updates for single position daily PnL values
reqId | |
pos | current size of the position |
dailyPnL | dailyPnL for the position |
unrealizedPnL | total unrealized PnL for the position (since inception) updating in real time |
value | current market value of the position |
void position | ( | string | account, |
Contract | contract, | ||
decimal | pos, | ||
double | avgCost | ||
) |
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. |
void positionEnd | ( | ) |
Indicates all the positions have been transmitted.
void positionMulti | ( | int | requestId, |
string | account, | ||
string | modelCode, | ||
Contract | contract, | ||
decimal | pos, | ||
double | avgCost | ||
) |
provides the portfolio's open positions.
requestId | the id of request |
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. |
void positionMultiEnd | ( | int | requestId) |
Indicates all the positions have been transmitted.
void realtimeBar | ( | int | reqId, |
long | date, | ||
double | open, | ||
double | high, | ||
double | low, | ||
double | close, | ||
decimal | volume, | ||
decimal | WAP, | ||
int | count | ||
) |
updates the real time 5 seconds bars
reqId | the request's identifier |
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). |
void receiveFA | ( | int | faDataType, |
string | faXmlData | ||
) |
receives the Financial Advisor's configuration available in the TWS
faDataType | one of:
|
faXmlData | the xml-formatted configuration |
void replaceFAEnd | ( | int | reqId, |
string | text | ||
) |
notifies the end of the FA replace.
reqId | the id of request |
text | the message text |
void rerouteMktDataReq | ( | int | reqId, |
int | conId, | ||
string | exchange | ||
) |
reqId | |
conId | of the underlying instrument which has market data |
exchange | of the underlying |
void rerouteMktDepthReq | ( | int | reqId, |
int | conId, | ||
string | exchange | ||
) |
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 | |
conId | |
exchange |
void scannerData | ( | int | reqId, |
int | rank, | ||
ContractDetails | contractDetails, | ||
string | distance, | ||
string | benchmark, | ||
string | projection, | ||
string | legsStr | ||
) |
provides the data resulting from the market scanner request.
reqid | the request's identifier. |
rank | the ranking within the response of this bar. |
contractDetails | the data's ContractDetails |
distance | according to query. |
benchmark | according to query. |
projection | according to query. |
legStr | describes the combo legs when the scanner is returning EFP |
void scannerDataEnd | ( | int | reqId) |
Indicates the scanner data reception has terminated.
reqId | the request's identifier |
void scannerParameters | ( | string | xml) |
provides the xml-formatted parameters available from TWS market scanners (not all available in API).
xml | the xml-formatted string with the available parameters. |
void securityDefinitionOptionParameter | ( | int | reqId, |
string | exchange, | ||
int | underlyingConId, | ||
string | tradingClass, | ||
string | multiplier, | ||
HashSet< string > | expirations, | ||
HashSet< double > | strikes | ||
) |
returns 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 | ID of the request initiating the callback |
underlyingConId | The conID of the underlying security |
tradingClass | the option trading class |
multiplier | the option multiplier |
expirations | a list of the expiries for the options of this underlying on this exchange |
strikes | a list of the possible strikes for options of this underlying on this exchange |
void securityDefinitionOptionParameterEnd | ( | int | reqId) |
called when all callbacks to securityDefinitionOptionParameter are complete
reqId | the ID used in the call to securityDefinitionOptionParameter |
void smartComponents | ( | int | reqId, |
Dictionary< int, KeyValuePair< string, char >> | theMap | ||
) |
bit number to exchange + exchange abbreviation dictionary
reqId | |
theMap | sa EClient::reqSmartComponents |
void softDollarTiers | ( | int | reqId, |
SoftDollarTier[] | tiers | ||
) |
called when receives Soft Dollar Tier configuration information
reqId | The request ID used in the call to EClient::reqSoftDollarTiers |
tiers | Stores a list of SoftDollarTier that contains all Soft Dollar Tiers information |
void symbolSamples | ( | int | reqId, |
ContractDescription[] | contractDescriptions | ||
) |
returns array of sample contract descriptions
ContractDescription[] |
void tickByTickAllLast | ( | int | reqId, |
int | tickType, | ||
long | time, | ||
double | price, | ||
decimal | size, | ||
TickAttribLast | tickAttribLast, | ||
string | exchange, | ||
string | specialConditions | ||
) |
returns "Last" or "AllLast" tick-by-tick real-time tick
reqId | - unique identifier of the request |
tickType | - tick-by-tick real-time tick type: "Last" or "AllLast" |
time | - tick-by-tick real-time tick timestamp |
price | - tick-by-tick real-time tick last price |
size | - tick-by-tick real-time tick last size |
tickAttribLast | - tick-by-tick real-time last tick attribs (bit 0 - past limit, bit 1 - unreported) |
exchange | - tick-by-tick real-time tick exchange |
specialConditions | - tick-by-tick real-time tick special conditions |
void tickByTickBidAsk | ( | int | reqId, |
long | time, | ||
double | bidPrice, | ||
double | askPrice, | ||
decimal | bidSize, | ||
decimal | askSize, | ||
TickAttribBidAsk | tickAttribBidAsk | ||
) |
returns "BidAsk" tick-by-tick real-time tick
reqId | - unique identifier of the request |
time | - tick-by-tick real-time tick timestamp |
bidPrice | - tick-by-tick real-time tick bid price |
askPrice | - tick-by-tick real-time tick ask price |
bidSize | - tick-by-tick real-time tick bid size |
askSize | - tick-by-tick real-time tick ask size |
tickAttribBidAsk | - tick-by-tick real-time bid/ask tick attribs (bit 0 - bid past low, bit 1 - ask past high) |
void tickByTickMidPoint | ( | int | reqId, |
long | time, | ||
double | midPoint | ||
) |
returns "MidPoint" tick-by-tick real-time tick
reqId | - unique identifier of the request |
time | - tick-by-tick real-time tick timestamp |
midPoint | - tick-by-tick real-time tick mid point |
void tickEFP | ( | int | tickerId, |
int | tickType, | ||
double | basisPoints, | ||
string | formattedBasisPoints, | ||
double | impliedFuture, | ||
int | holdDays, | ||
string | futureLastTradeDate, | ||
double | dividendImpact, | ||
double | dividendsToLastTradeDate | ||
) |
Exchange for Physicals.
tickerId | 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. |
void tickGeneric | ( | int | tickerId, |
int | field, | ||
double | value | ||
) |
Market data callback.
tickerId | the request's unique identifier. |
field | the type of tick being received. |
value |
void tickNews | ( | int | tickerId, |
long | timeStamp, | ||
string | providerCode, | ||
string | articleId, | ||
string | headline, | ||
string | extraData | ||
) |
ticks with news headline
tickerId | |
timeStamp | |
providerCode | |
articleId | |
headline | |
extraData |
void tickOptionComputation | ( | int | tickerId, |
int | field, | ||
int | tickAttrib, | ||
double | impliedVolatility, | ||
double | delta, | ||
double | optPrice, | ||
double | pvDividend, | ||
double | gamma, | ||
double | vega, | ||
double | theta, | ||
double | undPrice | ||
) |
Receive's option specific market data. This method is called when the market in an option or its underlier moves. TWS’s option model volatilities, prices, and deltas, along with the present value of dividends expected on that options underlier are received.
tickerId | the request's unique identifier. |
field | Specifies the type of option computation. Pass the field value into TickType.getField(int tickType) 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. |
tickAttrib,: | 0 - return based, 1- price based. |
delta | the option delta 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. |
void tickPrice | ( | int | tickerId, |
int | field, | ||
double | price, | ||
TickAttrib | attribs | ||
) |
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).
tickerId | the request's unique identifier. |
field | the type of the price being received (i.e. ask price). |
price | the actual price. |
attribs | an TickAttrib object that contains price attributes such as TickAttrib::CanAutoExecute, TickAttrib::PastLimit and TickAttrib::PreOpen. |
void tickReqParams | ( | int | tickerId, |
double | minTick, | ||
string | bboExchange, | ||
int | snapshotPermissions | ||
) |
tick with BOO exchange and snapshot permissions
tickerId | |
minTick | |
bboExchange | |
snapshotPermissions | sa EClient::reqMktData |
void tickSize | ( | int | tickerId, |
int | field, | ||
decimal | size | ||
) |
Market data tick size callback. Handles all size-related ticks.
tickerId | the request's unique identifier. |
field | the type of size being received (i.e. bid size) |
size | the actual size. US stocks have a multiplier of 100. |
void tickString | ( | int | tickerId, |
int | field, | ||
string | value | ||
) |
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.
tickerId | the request's unique identifier. |
field | the type of the tick being received |
void updateAccountTime | ( | string | timestamp) |
Receives the last time on which the account was updated.
timestamp | the last update system time. |
void updateAccountValue | ( | string | key, |
string | value, | ||
string | currency, | ||
string | accountName | ||
) |
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.
|
value | up-to-date value |
currency | the currency on which the value is expressed. |
accountName | the account |
void updateMktDepth | ( | int | tickerId, |
int | position, | ||
int | operation, | ||
int | side, | ||
double | price, | ||
decimal | size | ||
) |
Returns the order book.
tickerId | the request's identifier |
position | the order book's row being updated |
operation | how to refresh the row: 0 = insert (insert this new order into the row identified by 'position')· 1 = update (update the existing order in the row identified by 'position')· 2 = delete (delete the existing order at the row identified by 'position'). |
side | 0 for ask, 1 for bid |
price | the order's price |
size | the order's size |
void updateMktDepthL2 | ( | int | tickerId, |
int | position, | ||
string | marketMaker, | ||
int | operation, | ||
int | side, | ||
double | price, | ||
decimal | size, | ||
bool | isSmartDepth | ||
) |
Returns the order book.
tickerId | 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: 0 - insert (insert this new order into the row identified by 'position')· 1 - update (update the existing order in the row identified by 'position')· 2 - delete (delete the existing order at the row identified by 'position'). |
side | 0 for ask, 1 for bid |
price | the order's price |
size | the order's size |
isSmartDepth | flag indicating if this is smart depth response (aggregate data from multiple exchanges, v974+) |
void updateNewsBulletin | ( | int | msgId, |
int | msgType, | ||
string | message, | ||
string | origExchange | ||
) |
provides IB's bulletins
msgId | the bulletin's identifier |
msgType | one of: 1 - Regular news bulletin 2 - Exchange no longer available for trading 3 - Exchange is available for trading |
message | the message |
origExchange | the exchange where the message comes from. |
void updatePortfolio | ( | Contract | contract, |
decimal | position, | ||
double | marketPrice, | ||
double | marketValue, | ||
double | averageCost, | ||
double | unrealizedPNL, | ||
double | realizedPNL, | ||
string | accountName | ||
) |
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 EClientSocket::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. |
void userInfo | ( | int | reqId, |
string | whiteBrandingId | ||
) |
void wshEventData | ( | int | reqId, |
string | dataJson | ||
) |
returns calendar events from the WSH
reqId | the id of request |
dataJson | event data in json format |
void wshMetaData | ( | int | reqId, |
string | dataJson | ||
) |
returns meta data from the WSH calendar
reqId | the id of request |
dataJson | metadata in json format |