IP API - update order?

Discussion in 'Automated Trading' started by foible, May 17, 2010.

  1. foible


    I'm working on a front-end for IB and I'd like to be able to update orders, even those that are created by different clients. When the order is created by the same client that's doing the update, the code is simple:

    order.m_transmit = true
    ibclient.placeOrder(order.m_orderId, contract, order)

    When the order comes from a different client, I will get a duplicate orderId error or code[135], msg[Can't find order with id =23018].

    I've debated just cancelling the order & resubmitting but since the order can be a part of a OCA group, cancelling outright will cancel all of the orders which is not what I want.

    I've tried setting the Client ID to 0, setting the m_clientId of the order and calling ibclient.reqAutoOpenOrders(true) to bind the orders to the app, and while I am getting non-zero order IDs, I can't find a way to modify them.

    Has anyone worked around this before? Does anyone have any guesses or ideas to try? I've exhausted all my bright ideas here.

  2. rosy2


    simplest approach is put the orderIDs in a distributed hashtable or a cache (like memcache) then all the clients can use unique IDs and know what IDs other clients are using.
  3. In the order status event you receive also the clientId (it's one of the properties of the DTwsEvents_orderStatusEvent).

    So orders of other clients can simply be ignored.
    Each client will clearly deal with its own orders.

  4. rosy2


    he wants clients to update <b> any </b> order