• C#
  • Java
  • VB
  • C++
  • Python
Contact us
Component Exchanges

A single data request from the API can receive aggregate quotes from multiple exchanges. With API versions 9.72.18 and TWS 9.62 and higher, the tick types 'bidExch' (tick type 32), 'askExch' (tick type 33), 'lastExch' (tick type 84) are used to identify the source of a quote. To preserve bandwidth, the data returned to these tick types consists of a sequence of capital letters rather than a long list of exchange names for every returned exchange name field. To find the full exchange name corresponding to a single letter code returned in tick types 32, 33, or 84, and API function IBApi::EClient::reqSmartComponents is available. Note: This function can only be used when the exchange is open.

Different IB contracts have a different exchange map containing the set of exchanges on which they trade. Each exchange map has a different code, such as "a6" or "a9". This exchange mapping code is returned to IBApi::EWrapper::tickReqParams immediately after a market data request is made by a user with market data subscriptions. To find a particular map of single letter codes to full exchange names, the function reqSmartComponents is invoked with the exchange mapping code returned to tickReqParams.

  • client.reqSmartComponents(13002, testImpl.BboExchange);
  • client.reqSmartComponents(1013, "a6");
  • client.reqSmartComponents(13002, wrapperImpl.BboExchange)
  • m_pClient->reqSmartComponents(13002, m_bboExchange);
  • 1  # Requests description of map of single letter exchange codes to full exchange names
    2  self.reqSmartComponents(1018, "a6")

For instance, a market data request for the IBKR US contract may return the exchange mapping identifier "a6" to IBApi.EWrapper.tickReqParams . Invoking the function IBApi.EClient.reqSmartComponents with the symbol "a9" will reveal the list of exchanges offering market data for the IBKR US contract, and their single letter codes. The code for "ARCA" may be "P". In that case if "P" is returned to the exchange tick types, that would indicate the quote was provided by ARCA.

  • public void smartComponents(int reqId, Dictionary<int, KeyValuePair<string, char>> theMap)
    {
    StringBuilder sb = new StringBuilder();
    sb.AppendFormat("==== Smart Components Begin (total={0}) reqId = {1} ====\n", theMap.Count, reqId);
    foreach (var item in theMap)
    {
    sb.AppendFormat("bit number: {0}, exchange: {1}, exchange letter: {2}\n", item.Key, item.Value.Key, item.Value.Value);
    }
    sb.AppendFormat("==== Smart Components Begin (total={0}) reqId = {1} ====\n", theMap.Count, reqId);
    Console.WriteLine(sb);
    }
  • @Override
    public void smartComponents(int reqId, Map<Integer, Entry<String, Character>> theMap) {
    System.out.println(EWrapperMsgGenerator.smartComponents(reqId, theMap));
    }
  • Public Sub smartComponents(reqId As Integer, theMap As Dictionary(Of Integer, KeyValuePair(Of String, Char))) Implements EWrapper.smartComponents
    Dim sb As New StringBuilder
    sb.AppendFormat("==== Smart Components Begin (total={0}) reqId = {1} ===={2}", theMap.Count, reqId, Environment.NewLine)
    For Each item In theMap
    sb.AppendFormat("bit number: {0}, exchange: {1}, exchange letter: {2}{3}", item.Key, item.Value.Key, item.Value.Value, Environment.NewLine)
    Next
    sb.AppendFormat("==== Smart Components Begin (total={0}) reqId = {1} ===={2}", theMap.Count, reqId, Environment.NewLine)
    Console.WriteLine(sb)
    End Sub
  • void TestCppClient::smartComponents(int reqId, const SmartComponentsMap& theMap) {
    printf("Smart components: (%lu):\n", theMap.size());
    for (SmartComponentsMap::const_iterator i = theMap.begin(); i != theMap.end(); i++) {
    printf(" bit number: %d exchange: %s exchange letter: %c\n", i->first, std::get<0>(i->second).c_str(), std::get<1>(i->second));
    }
    }
  • 1  def smartComponents(self, reqId:int, smartComponentMap:SmartComponentMap):
    2  super().smartComponents(reqId, smartComponentMap)
    3  print("SmartComponents:")
    4  for smartComponent in smartComponentMap:
    5  print("SmartComponent.", smartComponent)