How could we use ibpy for editing orders?

江枫思渺然 提交于 2019-12-25 08:16:57

问题


I know that in ibpy I could place order to create a new order:

    self._tws.placeOrder(order_id,contract, order)

However, suppose I know want to change the limit price of some already placed order. Is there anything like:?

    self._tws.editOrder(order_id,contract, order)

Or simply use place order with the specific order_id is ok?


回答1:


You just call placeOrder again with the same orderId but with changed data. You can only change certain fields but m_lmtPrice is easy.

From the docs,

Modification of an open order through the API can be achieved by the same client which placed the original order. In the case of orders placed manually in TWS, the order can be modified by the client with ID 0.

To modify an order, simply call the IBApi.EClient.placeOrder function again with the same parameters used to place the original order, except for the changed parameter. This includes the IBApi.Order.OrderId, which must match the IBApi.Order.OrderId of the original. It is not generally recommended to try to change order parameters other than the order price and order size. To change other parameters, it might be preferable to cancel the original order and place a new order.

Link http://interactivebrokers.github.io/tws-api/modifying_orders.html#gsc.tab=0



来源:https://stackoverflow.com/questions/41289239/how-could-we-use-ibpy-for-editing-orders

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!