Interactive Brokers API: How to get Routing Destination?

Discussion in 'Automated Trading' started by trader422, Aug 6, 2012.

  1. I don't think there is any way, using the API, to get the routing destination data field for an order working in Trader Workstation (that is, the field with TWS header "Destination"). Can anyone prove me wrong?

    After using the API for more than 10 years it just recently occurred to me that this would always have been really useful data to have, and would have solved a lot of problems over the years... not to mention, there seems to be no excuse for IB to not have provided it starting with version 1.0.
     
  2. the destination (SMART/ARCA/IDEALPRO/etc) is specified in the contract that is attached to the order, prior to sending.

    you may wish to look at the tradelink.org code for the tws connector in source-> brokerservers -> twsserver for an example
     
  3. Sorry, maybe I wasn't clear ... I'm talking about getting the routing destination for SMART routed orders that can get routed, and rerouted, anywhere after the order is transmitted.
     
  4. According to the docs, if you specify the "exchange" field of the IContract, you can route it using that.

    http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/activex/icontract.htm

    Try giving the exchange field a string such as "BATS" or whatever, and see where it goes.

    If you mean for orders that are active in TWS but not initiated by the API, then you'd have to keep track of that yourself using contract ID (conID) fields. At least I think so. I'm still not sure I understood your question though.
     
  5. Thanks for the post, braincell, but it sounds like you are talking about routing orders, whereas I'm just talking about finding the routing destination of already-routed orders ...

    I promise this question is simple, so I must not be making myself clear ... one more time:

    I've got a bunch of orders (U.S. equities) working. All the orders appear normally in TWS, and all the orders are fully known by my app using the API. TWS has a field with header "Destination" which reports the current routing destination for each order (NYSE, BATS, ISLAND, ARCA, etcetera). Since the orders were all SMART-routed, this data is unknown when I place the orders, plus for any order it might change at any time as the order gets rerouted.

    The question is: TWS reports this information accurately in real time, all the time ... so why can't I get it through the API? Or, can I get it through the API?
     
  6. Craig66

    Craig66

    The routed-to exchange is in the 'execution' message.
     
  7. Oh, I see. Like the poster before me said, it's probably in the execution reply you get.

    http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/activex/execdetails.htm

    Check out the cExchange or eExchange fields of that reply.

    I've had similar problems before. It would help a lot if IB sorted out their docs, otherwise you just have to try things out.
     
  8. No, unless I'm misunderstanding you, we're talking about limit orders that have not been executed and may never be executed...
     
  9. ask raymond at ib... api at interactivebrokers.com