• C#
  • Java
  • VB
  • C++
  • Python
Contact us
EWrapper Interface Reference

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)
 Errors sent by the TWS are received here. More...
 
void currentTime (long time)
 Server's current time. This method will receive IB server's system time resulting after the invokation of reqCurrentTime. More...
 
void tickPrice (int tickerId, int field, double price, TickAttrib attribs)
 Market data tick price callback. Handles all price related ticks. More...
 
void tickSize (int tickerId, int field, int size)
 Market data tick size callback. Handles all size-related ticks. More...
 
void tickString (int tickerId, int field, string value)
 Market data callback. 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, UnderComp underComp)
 
  • Upon accepting a Delta-Neutral DN RFQ(request for quote), the server sends a deltaNeutralValidation() message with the UnderComp 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 unitl the RFQ is cancelled.
More...
 
void tickOptionComputation (int tickerId, int field, 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.
 
void nextValidId (int orderId)
 Receives next valid order id. More...
 
void managedAccounts (string accountsList)
 Receives a comma-separated string with the managed account ids. More...
 
void connectionClosed ()
 Notifes when the API-TWS connectivity has been closed. 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. 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. More...
 
void updatePortfolio (Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealisedPNL, double realisedPNL, 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. 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, double filled, double remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, string whyHeld)
 Gives the up-to-date information of an order every time it changes. 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 definitons 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 Reuters' Fundamental data More...
 
void historicalData (int reqId, string date, double open, double high, double low, double close, int volume, int count, double WAP, bool hasGaps)
 returns the requested historical data bars 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, int size)
 Returns the order book. More...
 
void updateMktDepthL2 (int tickerId, int position, string marketMaker, int operation, int side, double price, int size)
 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, double 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 time, double open, double high, double low, double close, long volume, double WAP, int count)
 updates the real time 5 seconds bars More...
 
void scannerParameters (string xml)
 provides the xml-formatted parameters available to create a market scanner. 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)
 Deprecated Function.
 
void verifyCompleted (bool isSuccessful, string errorText)
 DOC_TODO.
 
void verifyAndAuthMessageAPI (string apiData, string xyzChallenge)
 DOC_TODO.
 
void verifyAndAuthCompleted (bool isSuccessful, string errorText)
 DOC_TODO.
 
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 signifying completion of successful connection
 
void positionMulti (int requestId, string account, string modelCode, Contract contract, double 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 apprevation 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 news providers 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)
 
  • returns beginning of data for contract for specified data type
More...
 
void histogramData (int reqId, Tuple< double, long >[] data)
 returns data histogram More...
 

Detailed Description

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.

See Also
EClientSocket class

Member Function Documentation

void accountDownloadEnd ( string  account)

Notifies when all the account's information has finished.

Parameters
accountthe account's id
See Also
updateAccountTime, updatePortfolio, updateAccountValue, EClientSocket::reqAccountUpdates
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.

Parameters
reqIdthe request's unique identifier.
accountthe account id
tagthe account's attribute being received.
  • AccountType — Identifies the IB account structure
  • NetLiquidation — The basis for determining the price of the assets in your account. Total cash value + stock value + options value + bond value
  • TotalCashValue — Total cash balance recognized at the time of trade + futures PNL
  • SettledCash — Cash recognized at the time of settlement - purchases at the time of trade - commissions - taxes - fees
  • AccruedCash — Total accrued cash value of stock, commodities and securities
  • BuyingPower — Buying power serves as a measurement of the dollar value of securities that one may purchase in a securities account without depositing additional funds
  • EquityWithLoanValue — Forms the basis for determining whether a client has the necessary assets to either initiate or maintain security positions. Cash + stocks + bonds + mutual funds
  • PreviousEquityWithLoanValue — Marginable Equity with Loan value as of 16:00 ET the previous day
  • GrossPositionValue — The sum of the absolute value of all stock and equity option positions
  • RegTEquity — Regulation T equity for universal account
  • RegTMargin — Regulation T margin for universal account
  • SMA — Special Memorandum Account: Line of credit created when the market value of securities in a Regulation T account increase in value
  • InitMarginReq — Initial Margin requirement of whole portfolio
  • MaintMarginReq — Maintenance Margin requirement of whole portfolio
  • AvailableFunds — This value tells what you have available for trading
  • ExcessLiquidity — This value shows your margin cushion, before liquidation
  • Cushion — Excess liquidity as a percentage of net liquidation value
  • FullInitMarginReq — Initial Margin of whole portfolio with no discounts or intraday credits
  • FullMaintMarginReq — Maintenance Margin of whole portfolio with no discounts or intraday credits
  • FullAvailableFunds — Available funds of whole portfolio with no discounts or intraday credits
  • FullExcessLiquidity — Excess liquidity of whole portfolio with no discounts or intraday credits
  • LookAheadNextChange — Time when look-ahead values take effect
  • LookAheadInitMarginReq — Initial Margin requirement of whole portfolio as of next period's margin change
  • LookAheadMaintMarginReq — Maintenance Margin requirement of whole portfolio as of next period's margin change
  • LookAheadAvailableFunds — This value reflects your available funds at the next margin change
  • LookAheadExcessLiquidity — This value reflects your excess liquidity at the next margin change
  • HighestSeverity — A measure of how close the account is to liquidation
  • DayTradesRemaining — The Number of Open/Close trades a user could put on before Pattern Day Trading is detected. A value of "-1" means that the user can put on unlimited day trades.
  • Leverage — GrossPositionValue / NetLiquidation
valuethe account's attribute's value.
currencythe currency on which the value is expressed.
See Also
accountSummaryEnd, EClientSocket::reqAccountSummary
void accountSummaryEnd ( int  reqId)

notifies when all the accounts' information has ben received.

Parameters
reqIdthe request's identifier.
See Also
accountSummary, EClientSocket::reqAccountSummary
void accountUpdateMulti ( int  requestId,
string  account,
string  modelCode,
string  key,
string  value,
string  currency 
)

provides the account updates.

Parameters
requestIdthe id of request
accountthe account with updates
modelCodethe model code with updates
keythe name of parameter
valuethe value of parameter
currencythe currency of parameter
See Also
accountUpdateMultiEnd, EClient::reqAccountUpdatesMulti
void accountUpdateMultiEnd ( int  requestId)

Indicates all the account updates have been transmitted.

See Also
EWrapper::accountUpdateMulti, EClientSocket::reqAccountUpdatesMulti
void bondContractDetails ( int  reqId,
ContractDetails  contract 
)

Delivers the Bond contract data after this has been requested via reqContractDetails.

Parameters
reqIdthe request's identifier
contractthe bond contract's information.
See Also
reqContractDetails
void commissionReport ( CommissionReport  commissionReport)
void connectionClosed ( )

Notifes when the API-TWS connectivity has been closed.

See Also
EClientSocket::eDisconnect
void contractDetails ( int  reqId,
ContractDetails  contractDetails 
)

receives the full contract's definitons This method will return all contracts matching the requested via EClientSocket::reqContractDetails. For example, one can obtain the whole option chain with it.

Parameters
reqIdthe unique request identifier
contractDetailsthe instrument's complete definition.
See Also
contractDetailsEnd, EClientSocket::reqContractDetails
void contractDetailsEnd ( int  reqId)

After all contracts matching the request were returned, this method will mark the end of their reception.

Parameters
reqIdthe request's identifier
See Also
contractDetails, EClientSocket::reqContractDetails
void currentTime ( long  time)

Server's current time. This method will receive IB server's system time resulting after the invokation of reqCurrentTime.

See Also
EClient::reqCurrentTime
void deltaNeutralValidation ( int  reqId,
UnderComp  underComp 
)

  • Upon accepting a Delta-Neutral DN RFQ(request for quote), the server sends a deltaNeutralValidation() message with the UnderComp 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 unitl the RFQ is cancelled.

Parameters
reqIdthe request's identifier.
underCompUnderlying Component
void displayGroupList ( int  reqId,
string  groups 
)

a one-time response to querying the display groups.

Parameters
reqIdthe ID of the request
Itreturns a list of integers representing visible Group ID separated by the "|" character, and sorted by most used group first.
See Also
EClientSocket::queryDisplayGroups
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.

Parameters
reqIdthe ID of the request
contractInfo
See Also
EClient::subscribeToGroupEvents
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.

Parameters
ethe thrown exception.
void error ( string  str)
Parameters
strThe error message received.
void error ( int  id,
int  errorCode,
string  errorMsg 
)

Errors sent by the TWS are received here.

Parameters
idthe request identifier which generated the error.
errorCodethe code identifying the error.
errorMsgerror's description.
void execDetails ( int  reqId,
Contract  contract,
Execution  execution 
)

Provides the executions which happened in the last 24 hours.

Parameters
reqIdthe request's identifier
contractthe Contract of the Order
executionthe Execution details.
See Also
execDetailsEnd, commissionReport, EClientSocket::reqExecutions, Execution
void execDetailsEnd ( int  reqId)

indicates the end of the Execution reception.

Parameters
reqIdthe request's identifier
See Also
execDetails, commissionReport, EClientSocket::reqExecutions
void familyCodes ( FamilyCode[]  familyCodes)

returns array of family codes

Parameters
FamilyCode[]
See Also
EClient::reqFamilyCodes
void fundamentalData ( int  reqId,
string  data 
)

returns Reuters' Fundamental data

Parameters
reqIdthe request's identifier
dataReuthers xml-formatted fundamental data
See Also
EClientSocket::reqFundamentalData
void headTimestamp ( int  reqId,
string  headTimestamp 
)

  • returns beginning of data for contract for specified data type

Parameters
requestId
headTimestamp- string identifying earliest data date
See Also
EClient::reqHeadTimestamp
void histogramData ( int  reqId,
Tuple< double, long >[]  data 
)

returns data histogram

Parameters
requestId
data- returned Tuple of histogram data, number of trades at specified price level
See Also
EClient::reqHistogramData
void historicalData ( int  reqId,
string  date,
double  open,
double  high,
double  low,
double  close,
int  volume,
int  count,
double  WAP,
bool  hasGaps 
)

returns the requested historical data bars

Parameters
reqIdthe request's identifier
datethe bar's date and time (either as a yyyymmss hh:mm:ss formatted string or as system time according to the request)
openthe bar's open point
highthe bar's high point
lowthe bar's low point
closethe bar's closing point
volumethe bar's traded volume if available
countthe number of trades during the bar's timespan (only available for TRADES).
WAPthe bar's Weighted Average Price
hasGapsindicates if the data has gaps or not.
See Also
EClientSocket::reqHistoricalData
void historicalNews ( int  requestId,
string  time,
string  providerCode,
string  articleId,
string  headline 
)

returns news headline

Parameters
requestId
time
providerCode
articleId
headline
See Also
EClient::reqHistoricalNews
void historicalNewsEnd ( int  requestId,
bool  hasMore 
)

returns news headlines end marker

Parameters
requestId
hasMore- indicates whether there are more results available, false otherwise
See Also
EClient::reqHistoricalNews
void managedAccounts ( string  accountsList)

Receives a comma-separated string with the managed account ids.

See Also
EClientSocket::reqManagedAccts
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.

Parameters
reqIdthe id of ticker sent in reqMktData
marketDataTypemeans that now API starts to tick with the folloiwng market data: 1 for real-time, 2 for frozen, 3 for delayed, 4 for delayed-frozen
See Also
EClientSocket::reqMarketDataType, EClientSocket::reqMktData
void mktDepthExchanges ( DepthMktDataDescription[]  depthMktDataDescriptions)

called when receives Depth Market Data Descriptions

Parameters
descriptionsStores a list of DepthMktDataDescriprion
See Also
EClient::reqMktDepthExchanges
void newsArticle ( int  requestId,
int  articleType,
string  articleText 
)

called when receives News Article

Parameters
requestIdThe request ID used in the call to EClient::reqNewsArticle
articleTypeThe type of news article (0 - plain text or html, 1 - binary data / pdf)
articleTextThe body of article (if articleType == 1, the binary data is encoded using the Base64 scheme)
See Also
EClient::reqNewsArticle
void newsProviders ( NewsProvider[]  newsProviders)

returns array of news providers

Parameters
NewsProvider[]
See Also
EClient::reqNewsProviders
void nextValidId ( int  orderId)

Receives next valid order id.

Parameters
orderIdthe next order id
See Also
EClientSocket::reqIds
void openOrder ( int  orderId,
Contract  contract,
Order  order,
OrderState  orderState 
)

Feeds in currently open orders.

Parameters
orderIdthe order's unique id
contractthe order's Contract.
orderthe currently active Order.
orderStatethe order's OrderState
See Also
orderStatus, openOrderEnd, EClientSocket::placeOrder, EClientSocket::reqAllOpenOrders, EClientSocket::reqAutoOpenOrders
void openOrderEnd ( )
void orderStatus ( int  orderId,
string  status,
double  filled,
double  remaining,
double  avgFillPrice,
int  permId,
int  parentId,
double  lastFillPrice,
int  clientId,
string  whyHeld 
)

Gives the up-to-date information of an order every time it changes.

Parameters
orderIdthe order's client id.
statusthe current status of the order: PendingSubmit - indicates that you have transmitted the order, but have not yet received confirmation that it has been accepted by the order destination. NOTE: This order status is not sent by TWS and should be explicitly set by the API developer when an order is submitted. 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. You may still receive an execution while your cancellation request is pending. NOTE: This order status is not sent by TWS and should be explicitly set by the API developer when an order is canceled. 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 at the order destination and is working. ApiCanceled - 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. Inactive - indicates that the order has been accepted by the system (simulated orders) or an exchange (native orders) but that currently the order is inactive due to system, exchange or other issues.
fillednumber of filled positions.
remainingthe remnant positions.
avgFillPriceaverage filling price.
permIdthe order's permId used by the TWs to identify orders.
parentIdparent's id. Used for bracker and auto trailing stop orders.
lastFillPriceprice at which the last positions were filled.
clientIdAPI client which submitted the order.
whyHeldthis 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'.
See Also
openOrder, openOrderEnd, EClientSocket::placeOrder, EClientSocket::reqAllOpenOrders, EClientSocket::reqAutoOpenOrders
void position ( string  account,
Contract  contract,
double  pos,
double  avgCost 
)

provides the portfolio's open positions.

Parameters
accountthe account holding the position.
contractthe position's Contract
posthe number of positions held. avgCost the average cost of the position.
See Also
positionEnd, EClientSocket::reqPositions
void positionEnd ( )

Indicates all the positions have been transmitted.

See Also
position, EClient::reqPositions
void positionMulti ( int  requestId,
string  account,
string  modelCode,
Contract  contract,
double  pos,
double  avgCost 
)

provides the portfolio's open positions.

Parameters
requestIdthe id of request
accountthe account holding the position.
modelCodethe model code holding the position.
contractthe position's Contract
posthe number of positions held. avgCost the average cost of the position.
See Also
positionMultiEnd, EClientSocket::reqPositionsMulti
void positionMultiEnd ( int  requestId)

Indicates all the positions have been transmitted.

See Also
positionMulti, EClient::reqPositionsMulti
void realtimeBar ( int  reqId,
long  time,
double  open,
double  high,
double  low,
double  close,
long  volume,
double  WAP,
int  count 
)

updates the real time 5 seconds bars

Parameters
reqIdthe request's identifier
datethe bar's date and time (either as a yyyymmss hh:mm:ss formatted string or as system time according to the request)
openthe bar's open point
highthe bar's high point
lowthe bar's low point
closethe bar's closing point
volumethe bar's traded volume if available
WAPthe bar's Weighted Average Price
countthe number of trades during the bar's timespan (only available for TRADES).
See Also
EClientSocket::reqRealTimeBars
void receiveFA ( int  faDataType,
string  faXmlData 
)

receives the Financial Advisor's configuration available in the TWS

Parameters
faDataTypeone of:
  1. Groups: offer traders a way to create a group of accounts and apply a single allocation method to all accounts in the group.
  2. Profiles: let you allocate shares on an account-by-account basis using a predefined calculation value.
  3. Account Aliases: let you easily identify the accounts by meaningful names rather than account numbers.
faXmlDatathe xml-formatted configuration
See Also
EClientSocket::requestFA, EClientSocket::replaceFA
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.

Parameters
reqidthe request's identifier.
rankthe ranking within the response of this bar.
contractDetailsthe data's ContractDetails
distanceaccording to query.
benchmarkaccording to query.
projectionaccording to query.
legStrdescribes the combo legs when the scanner is returning EFP
See Also
scannerParameters, scannerDataEnd, EClientSocket::reqScannerSubscription
void scannerDataEnd ( int  reqId)

Indicates the scanner data reception has terminated.

Parameters
reqIdthe request's identifier
See Also
scannerParameters, scannerData, EClientSocket::reqScannerSubscription
void scannerParameters ( string  xml)

provides the xml-formatted parameters available to create a market scanner.

Parameters
xmlthe xml-formatted string with the available parameters.
See Also
scannerData, EClientSocket::reqScannerParameters
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

Parameters
reqIdID of the request initiating the callback
underlyingConIdThe conID of the underlying security
tradingClassthe option trading class
multiplierthe option multiplier
expirationsa list of the expiries for the options of this underlying on this exchange
strikesa list of the possible strikes for options of this underlying on this exchange
See Also
EClient::reqSecDefOptParams
void securityDefinitionOptionParameterEnd ( int  reqId)

called when all callbacks to securityDefinitionOptionParameter are complete

Parameters
reqIdthe ID used in the call to securityDefinitionOptionParameter
See Also
securityDefinitionOptionParameter, EClient::reqSecDefOptParams
void smartComponents ( int  reqId,
Dictionary< int, KeyValuePair< string, char >>  theMap 
)

bit number to exchange + exchange apprevation dictionary

Parameters
reqId
theMapsa EClient::reqSmartComponents
void softDollarTiers ( int  reqId,
SoftDollarTier[]  tiers 
)

called when receives Soft Dollar Tier configuration information

Parameters
reqIdThe request ID used in the call to EClient::reqSoftDollarTiers
tiersStores a list of SoftDollarTier that contains all Soft Dollar Tiers information
See Also
EClient::reqSoftDollarTiers
void symbolSamples ( int  reqId,
ContractDescription[]  contractDescriptions 
)

returns array of sample contract descriptions

Parameters
ContractDescription[]
See Also
EClient::reqMatchingSymbols
void tickEFP ( int  tickerId,
int  tickType,
double  basisPoints,
string  formattedBasisPoints,
double  impliedFuture,
int  holdDays,
string  futureLastTradeDate,
double  dividendImpact,
double  dividendsToLastTradeDate 
)

Exchange for Physicals.

Parameters
tickerIdThe request's identifier.
tickTypeThe type of tick being received.
basisPointsAnnualized basis points, which is representative of the financing rate that can be directly compared to broker rates.
formattedBasisPointsAnnualized basis points as a formatted string that depicts them in percentage form.
impliedFutureThe implied Futures price.
holdDaysThe number of hold days until the lastTradeDate of the EFP.
futureLastTradeDateThe expiration date of the single stock future.
dividendImpactThe dividend impact upon the annualized basis points interest rate.
dividendsToLastTradeDateThe dividends expected until the expiration of the single stock future.
void tickGeneric ( int  tickerId,
int  field,
double  value 
)

Market data callback.

Parameters
tickerIdthe request's unique identifier.
fieldthe type of tick being received.
value
void tickNews ( int  tickerId,
long  timeStamp,
string  providerCode,
string  articleId,
string  headline,
string  extraData 
)

ticks with news headline

Parameters
tickerId
timeStamp
providerCode
articleId
headline
extraData
See Also
EClient::reqMktData
void tickOptionComputation ( int  tickerId,
int  field,
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.

Parameters
tickerIdthe request's unique identifier.
fieldSpecifies 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
impliedVolatilitythe implied volatility calculated by the TWS option modeler, using the specified tick type value.
deltathe option delta value.
optPricethe option price.
pwDividendthe present value of dividends expected on the option's underlying.
gammathe option gamma value.
vegathe option vega value.
thetathe option theta value.
undPricethe price of the underlying.
See Also
TickType, tickSize, tickPrice, tickEFP, tickGeneric, tickString, tickSnapshotEnd, marketDataType, EClientSocket::reqMktData
void tickPrice ( int  tickerId,
int  field,
double  price,
TickAttrib  attribs 
)

Market data tick price callback. Handles all price related ticks.

Parameters
tickerIdthe request's unique identifier.
fieldthe type of the price being received (i.e. ask price).
pricethe actual price.
canAutoExecuteSpecifies whether the price tick is available for automatic execution (1) or not (0).
See Also
TickType, tickSize, tickString, tickEFP, tickGeneric, tickOptionComputation, tickSnapshotEnd, marketDataType, EClientSocket::reqMktData
void tickReqParams ( int  tickerId,
double  minTick,
string  bboExchange,
int  snapshotPermissions 
)

tick with BOO exchange and snapshot permissions

Parameters
tickerId
minTick
bboExchange
snapshotPermissionssa EClient::reqMktData
void tickSize ( int  tickerId,
int  field,
int  size 
)

Market data tick size callback. Handles all size-related ticks.

Parameters
tickerIdthe request's unique identifier.
fieldthe type of size being received (i.e. bid size)
sizethe actual size.
See Also
TickType, tickPrice, tickString, tickEFP, tickGeneric, tickOptionComputation, tickSnapshotEnd, marketDataType, EClientSocket::reqMktData
void tickString ( int  tickerId,
int  field,
string  value 
)

Market data callback.

Parameters
tickerIdthe request's unique identifier.
fieldthe type of the tick being received
value
See Also
TickType, tickSize, tickPrice, tickEFP, tickGeneric, tickOptionComputation, tickSnapshotEnd, marketDataType, EClientSocket::reqMktData
void updateAccountTime ( string  timestamp)

Receives the last time on which the account was updated.

Parameters
timestampthe last update system time.
See Also
updatePortfolio, accountDownloadEnd, updateAccountValue, EClientSocket::reqAccountUpdates
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.

Parameters
keythe value being updated.
  • AccountCode — The account ID number
  • AccountOrGroup — "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
  • AccountReady — For internal use only
  • AccountType — Identifies the IB account structure
  • AccruedCash — Total accrued cash value of stock, commodities and securities
  • AccruedCash-C — Reflects the current's month accrued debit and credit interest to date, updated daily in commodity segment
  • AccruedCash-S — Reflects the current's month accrued debit and credit interest to date, updated daily in security segment
  • AccruedDividend — Total portfolio value of dividends accrued
  • AccruedDividend-C — Dividends accrued but not paid in commodity segment
  • AccruedDividend-S — Dividends accrued but not paid in security segment
  • AvailableFunds — This value tells what you have available for trading
  • AvailableFunds-C — Net Liquidation Value - Initial Margin
  • AvailableFunds-S — Equity with Loan Value - Initial Margin
  • Billable — Total portfolio value of treasury bills
  • Billable-C — Value of treasury bills in commodity segment
  • Billable-S — Value of treasury bills in security segment
  • BuyingPower — Cash Account: Minimum (Equity with Loan Value, Previous Day Equity with Loan Value)-Initial Margin, Standard Margin Account: Minimum (Equity with Loan Value, Previous Day Equity with Loan Value) - Initial Margin *4
  • CashBalance — Cash recognized at the time of trade + futures PNL
  • CorporateBondValue — Value of non-Government bonds such as corporate bonds and municipal bonds
  • Currency — Open positions are grouped by currency
  • Cushion — Excess liquidity as a percentage of net liquidation value
  • DayTradesRemaining — Number of Open/Close trades one could do before Pattern Day Trading is detected
  • DayTradesRemainingT+1 — Number of Open/Close trades one could do tomorrow before Pattern Day Trading is detected
  • DayTradesRemainingT+2 — Number of Open/Close trades one could do two days from today before Pattern Day Trading is detected
  • DayTradesRemainingT+3 — Number of Open/Close trades one could do three days from today before Pattern Day Trading is detected
  • DayTradesRemainingT+4 — Number of Open/Close trades one could do four days from today before Pattern Day Trading is detected
  • EquityWithLoanValue — Forms the basis for determining whether a client has the necessary assets to either initiate or maintain security positions
  • EquityWithLoanValue-C — Cash account: Total cash value + commodities option value - futures maintenance margin requirement + minimum (0, futures PNL) Margin account: Total cash value + commodities option value - futures maintenance margin requirement
  • EquityWithLoanValue-S — Cash account: Settled Cash Margin Account: Total cash value + stock value + bond value + (non-U.S. & Canada securities options value)
  • ExcessLiquidity — This value shows your margin cushion, before liquidation
  • ExcessLiquidity-C — Equity with Loan Value - Maintenance Margin
  • ExcessLiquidity-S — Net Liquidation Value - Maintenance Margin
  • ExchangeRate — The exchange rate of the currency to your base currency
  • FullAvailableFunds — Available funds of whole portfolio with no discounts or intraday credits
  • FullAvailableFunds-C — Net Liquidation Value - Full Initial Margin
  • FullAvailableFunds-S — Equity with Loan Value - Full Initial Margin
  • FullExcessLiquidity — Excess liquidity of whole portfolio with no discounts or intraday credits
  • FullExcessLiquidity-C — Net Liquidation Value - Full Maintenance Margin
  • FullExcessLiquidity-S — Equity with Loan Value - Full Maintenance Margin
  • FullInitMarginReq — Initial Margin of whole portfolio with no discounts or intraday credits
  • FullInitMarginReq-C — Initial Margin of commodity segment's portfolio with no discounts or intraday credits
  • FullInitMarginReq-S — Initial Margin of security segment's portfolio with no discounts or intraday credits
  • FullMaintMarginReq — Maintenance Margin of whole portfolio with no discounts or intraday credits
  • FullMaintMarginReq-C — Maintenance Margin of commodity segment's portfolio with no discounts or intraday credits
  • FullMaintMarginReq-S — Maintenance Margin of security segment's portfolio with no discounts or intraday credits
  • FundValue — Value of funds value (money market funds + mutual funds)
  • FutureOptionValue — Real-time market-to-market value of futures options
  • FuturesPNL — Real-time changes in futures value since last settlement
  • FxCashBalance — Cash balance in related IB-UKL account
  • GrossPositionValue — Gross Position Value in securities segment
  • GrossPositionValue-S — Long Stock Value + Short Stock Value + Long Option Value + Short Option Value
  • IndianStockHaircut — Margin rule for IB-IN accounts
  • InitMarginReq — Initial Margin requirement of whole portfolio
  • InitMarginReq-C — Initial Margin of the commodity segment in base currency
  • InitMarginReq-S — Initial Margin of the security segment in base currency
  • IssuerOptionValue — Real-time mark-to-market value of Issued Option
  • Leverage-S — GrossPositionValue / NetLiquidation in security segment
  • LookAheadNextChange — Time when look-ahead values take effect
  • LookAheadAvailableFunds — This value reflects your available funds at the next margin change
  • LookAheadAvailableFunds-C — Net Liquidation Value - look ahead Initial Margin
  • LookAheadAvailableFunds-S — Equity with Loan Value - look ahead Initial Margin
  • LookAheadExcessLiquidity — This value reflects your excess liquidity at the next margin change
  • LookAheadExcessLiquidity-C — Net Liquidation Value - look ahead Maintenance Margin
  • LookAheadExcessLiquidity-S — Equity with Loan Value - look ahead Maintenance Margin
  • LookAheadInitMarginReq — Initial margin requirement of whole portfolio as of next period's margin change
  • LookAheadInitMarginReq-C — Initial margin requirement as of next period's margin change in the base currency of the account
  • LookAheadInitMarginReq-S — Initial margin requirement as of next period's margin change in the base currency of the account
  • LookAheadMaintMarginReq — Maintenance margin requirement of whole portfolio as of next period's margin change
  • LookAheadMaintMarginReq-C — Maintenance margin requirement as of next period's margin change in the base currency of the account
  • LookAheadMaintMarginReq-S — Maintenance margin requirement as of next period's margin change in the base currency of the account
  • MaintMarginReq — Maintenance Margin requirement of whole portfolio
  • MaintMarginReq-C — Maintenance Margin for the commodity segment
  • MaintMarginReq-S — Maintenance Margin for the security segment
  • MoneyMarketFundValue — Market value of money market funds excluding mutual funds
  • MutualFundValue — Market value of mutual funds excluding money market funds
  • NetDividend — The sum of the Dividend Payable/Receivable Values for the securities and commodities segments of the account
  • NetLiquidation — The basis for determining the price of the assets in your account
  • NetLiquidation-C — Total cash value + futures PNL + commodities options value
  • NetLiquidation-S — Total cash value + stock value + securities options value + bond value
  • NetLiquidationByCurrency — Net liquidation for individual currencies
  • OptionMarketValue — Real-time mark-to-market value of options
  • PASharesValue — Personal Account shares value of whole portfolio
  • PASharesValue-C — Personal Account shares value in commodity segment
  • PASharesValue-S — Personal Account shares value in security segment
  • PostExpirationExcess — Total projected "at expiration" excess liquidity
  • PostExpirationExcess-C — Provides a projected "at expiration" excess liquidity based on the soon-to expire contracts in your portfolio in commodity segment
  • PostExpirationExcess-S — Provides a projected "at expiration" excess liquidity based on the soon-to expire contracts in your portfolio in security segment
  • PostExpirationMargin — Total projected "at expiration" margin
  • PostExpirationMargin-C — Provides a projected "at expiration" margin value based on the soon-to expire contracts in your portfolio in commodity segment
  • PostExpirationMargin-S — Provides a projected "at expiration" margin value based on the soon-to expire contracts in your portfolio in security segment
  • PreviousDayEquityWithLoanValue — Marginable Equity with Loan value as of 16:00 ET the previous day in securities segment
  • PreviousDayEquityWithLoanValue-S — IMarginable Equity with Loan value as of 16:00 ET the previous day
  • RealCurrency — Open positions are grouped by currency
  • RealizedPnL — Shows your profit on closed positions, which is the difference between your entry execution cost and exit execution costs, or (execution price + commissions to open the positions) - (execution price + commissions to close the position)
  • RegTEquity — Regulation T equity for universal account
  • RegTEquity-S — Regulation T equity for security segment
  • RegTMargin — Regulation T margin for universal account
  • RegTMargin-S — Regulation T margin for security segment
  • SMA — Line of credit created when the market value of securities in a Regulation T account increase in value
  • SMA-S — Regulation T Special Memorandum Account balance for security segment
  • SegmentTitle — Account segment name
  • StockMarketValue — Real-time mark-to-market value of stock
  • TBondValue — Value of treasury bonds
  • TBillValue — Value of treasury bills
  • TotalCashBalance — Total Cash Balance including Future PNL
  • TotalCashValue — Total cash value of stock, commodities and securities
  • TotalCashValue-C — CashBalance in commodity segment
  • TotalCashValue-S — CashBalance in security segment
  • TradingType-S — Account Type
  • UnrealizedPnL — The difference between the current market value of your open positions and the average cost, or Value - Average Cost
  • WarrantValue — Value of warrants
  • WhatIfPMEnabled — To check projected margin requirements under Portfolio Margin model
valueup-to-date value
currencythe currency on which the value is expressed.
accountNamethe account
See Also
updatePortfolio, updateAccountTime, accountDownloadEnd, EClientSocket::reqAccountUpdates
void updateMktDepth ( int  tickerId,
int  position,
int  operation,
int  side,
double  price,
int  size 
)

Returns the order book.

Parameters
tickerIdthe request's identifier
positionthe order book's row being updated
operationhow 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').
side0 for ask, 1 for bid
pricethe order's price
sizethe order's size
See Also
updateMktDepthL2, EClientSocket::reqMarketDepth
void updateMktDepthL2 ( int  tickerId,
int  position,
string  marketMaker,
int  operation,
int  side,
double  price,
int  size 
)

Returns the order book.

Parameters
tickerIdthe request's identifier
positionthe order book's row being updated
marketMakerthe exchange holding the order
operationhow 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').
side0 for ask, 1 for bid
pricethe order's price
sizethe order's size
See Also
updateMktDepth, EClientSocket::reqMarketDepth
void updateNewsBulletin ( int  msgId,
int  msgType,
String  message,
String  origExchange 
)

provides IB's bulletins

Parameters
msgIdthe bulletin's identifier
msgTypeone of: 1 - Regular news bulletin 2 - Exchange no longer available for trading 3 - Exchange is available for trading
messagethe message
origExchangethe exchange where the message comes from.
void updatePortfolio ( Contract  contract,
double  position,
double  marketPrice,
double  marketValue,
double  averageCost,
double  unrealisedPNL,
double  realisedPNL,
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.

Parameters
contractthe Contract for which a position is held.
positionthe number of positions held.
marketPriceinstrument's unitary price
marketValuetotal market value of the instrument.
See Also
updateAccountTime, accountDownloadEnd, updateAccountValue, EClientSocket::reqAccountUpdates