當使用ibpy手動關閉交易平臺上的某些頭寸時,它會變成我們無法做到的。具體而言,在執行時:IBpy無法取消手動放置的開倉訂單
self._tws.reqAllOpenOrders()
sleep(0.2)
我們取得編號爲0級(可能是因爲我placecd它手動上TWS)
<openOrder orderId=0, contract=<ib.ext.Contract.Contract object at 0x103b78ad0>, order=<ib.ext.Order.Order object at 0x103b78a50>, orderState=<ib.ext.OrderState.OrderState object at 0x103b78b10>>
<orderStatus orderId=0, status=Submitted, filled=0, remaining=100, avgFillPrice=0.0, permId=134994568, parentId=0, lastFillPrice=0.0, clientId=0, whyHeld=None>
<openOrder orderId=0, contract=<ib.ext.Contract.Contract object at 0x103b78c90>, order=<ib.ext.Order.Order object at 0x103b78c50>, orderState=<ib.ext.OrderState.OrderState object at 0x103b78cd0>>
<orderStatus orderId=0, status=Submitted, filled=0, remaining=1, avgFillPrice=0.0, permId=134994562, parentId=0, lastFillPrice=0.0, clientId=0, whyHeld=None>
<openOrderEnd>
當試圖與關閉:
self._tws.cancelOrder(0)
或
self._tws.cancelOrder(134994568)
我得到錯誤:
<error id=0, errorCode=135, errorMsg=Can't find order with id =0>
<error id=134994562, errorCode=135, errorMsg=Can't find order with id =134994562>
任何想法我們怎麼能關閉它們?謝謝。
非常感謝。你想花一些時間回答這個問題嗎? http://stackoverflow.com/questions/41289239/how-could-we-use-ibpy-for-editing-orders –