twsib-api

Where is defined which callback used for specific method in EClient


I'm just starting to use the IB API in python. I'm able to retrieve all the desired results I want. However, one big problem arise to me. I don't fully understand how the linkage between the EClient class and a particular callback is made within the EWrapper class.

As of now I understand the workflow like this (high level):

  1. An EClient instance makes a call to IB Gateway.
  2. IB Gateway itself reach out to the IB Data centers to fetch data
  3. Data comes back to IB Gateway
  4. IB Gateway calls the callback, which is the interface

As far as I understand, IB Gateway triggers the correct Callback function. What I don't see from the documentation / source code is the connection between a EClient method and a the interface (callback) I override in my EWrapper class. When I trigger a specific method in step 1 above. How does IB Gateway know, which callback to run? Is this specified somewhere?


Solution

  • The callback functions which handle responses to each function called in EClient are hard-coded and detailed in the TWS API Reference Guide.

    For instance, calling EClient.reqAccountUpdates causes responses to be returned in EWrapper::updateAccountValue and EWrapper::updatePortfolio, and you would need to override those functions in your own code.