我们如何使用ibpy来编辑订单?

问题描述:

我知道在ibpy中,我可以下订单以创建新订单:

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)

还是仅使用具有特定order_id的下订单即可?

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

您只需使用相同的orderId,但更改的数据再次调用placeOrder.您只能更改某些字段,但是m_lmtPrice很简单.

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

从文档中

通过API修改未结订单可以通过以下方式实现: 下了原始订单的同一位客户.在订货的情况下 手动放置在交易平台中,客户可以使用以下命令修改订单 ID 0.

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.

要修改订单,只需调用IBApi.EClient.placeOrder函数 再次使用用于下达原始订单的相同参数, 除了更改的参数.这包括 IBApi.Order.OrderId,它必须与 原版的.通常不建议尝试更改订单 订单价格和订单大小以外的参数.改变其他 参数,则取消原始订单和 下新订单.

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.

链接 http://interactivebrokers.github.io/tws-api/modified_orders.html#gsc.tab = 0