Modification of an API order can be done if the API client is connected to a session of TWS with the same username of TWS and using the same API client ID. The function IBApi.EClient.placeOrder can then be called with the same fields as the open order, except for the parameter to modify. This includes the IBApi.Order.OrderId, which must match the IBApi.Order.OrderId of the open order. It is not generally recommended to try to change order fields aside from order price, size, and tif (for DAY -> IOC modifications). To change other parameters, it might be preferable to instead cancel the open order, and create a new one.
- To modify or cancel an individual order placed manually from TWS, it is necessary to connect with client ID 0 and then bind the order before attempting to modify it. The process of binding assigns the order an API order ID; prior to binding it will be returned to the API with an API order ID of 0. Orders with API order ID 0 cannot be modified/cancelled from the API. The function reqOpenOrders binds orders open at that moment which do not already have an API order ID, and the function reqAutoOpenOrders binds future orders automatically. The function reqAllOpenOrders does not bind orders.
- To modify API orders when connecting to a different session of TWS (logged in with a different username than used for the original order), it is necessary to first bind the order with client ID 0 in the same manner as manual TWS orders are bound before they can be modified. The binding assignment of API order IDs is independent for each TWS user, so the same order can have different API order IDs for different users. The permID returned in the API Order class which is assigned by TWS can be used to identify an order in an account uniquely.
- Currently (as of TWS version 970) the process of order binding from the API cancels/resubmits an order working on an exchange. This may affect the order's place in the exchange queue. Enhancements are planned to allow for API binding with modification of exchange queue priority.