Closed Blair129 closed 8 months ago
Exactly the same issue here! I have a similar setup for a bracket order, like so:
parent = LimitOrder(direction, buy_amount, buyprice)
parent.algoStrategy = 'Adaptive'
parent.algoParams = listTagValues
parent.orderId = ib.client.getReqId()
parent.clientId = client
parent.outsideRth = True
parent.transmit = False
takeProfit = LimitOrder(oppositeDirection, buy_amount, profittakePrice)
takeProfit.orderId = parent.orderId + 1
takeProfit.parentId = parent.orderId
takeProfit.clientId = client
takeProfit.transmit = False
stopLoss = StopOrder(oppositeDirection, buy_amount, stoplossPrice)
stopLoss.orderId = parent.orderId + 2
stopLoss.parentId = parent.orderId
stopLoss.clientId = client
stopLoss.outsideRth = True
stopLoss.transmit = True
bracketOrder = [parent, takeProfit, stopLoss]
es_runningStopLossorder = stopLoss
for o in bracketOrder:
boughtOrder = ib.placeOrder(contract, o)
ib.sleep(0)
boughtOrders.append(boughtOrder)
Then when I try to update the SL part of this bracket:
es_runningStopLossorder.auxPrice = newStop
ib.placeOrder(es_contract, es_runningStopLossorder)
I get the same error as described above. That it cant find the order with the ID of the parent.
This might be only for futures, as I think it works for options (needs retest).
As an added note, this seems to be linked to the client (version)? I have tried my python app with the TWS Gateway and it didn't throw this error yet. Might be something in TWS 10.25?
I have the same issue, and I'm using the TWS Gateway version 10.19. @nuxy69 @Blair129 were you able to fix reliably fix this issue on your end?
I have the same issue, and I'm using the TWS Gateway version 10.19. @nuxy69 @Blair129 were you able to fix reliably fix this issue on your end?
Sadly no. Haven't found a fix yet...
Ok, would you try submitting a bracket order during market hours while ensuring that all prices are rounded to 2 significant digits? You can also turn on the API logging in the TWS Gateway. It said in the log that I have to enter a valid number. I was entering floating point numbers for the order prices with many significant digits, e.g. 43.1295343. Funny enough, 0 doesn't work either, minimum is 0.01 which is 1 cent. Hope it helps!
Ok, would you try submitting a bracket order during market hours while ensuring that all prices are rounded to 2 significant digits? You can also turn on the API logging in the TWS Gateway. It said in the log that I have to enter a valid number. I was entering floating point numbers for the order prices with many significant digits, e.g. 43.1295343. Funny enough, 0 doesn't work either, minimum is 0.01 which is 1 cent. Hope it helps!
That didn't do it sadly. I rounded everything off to .25 increments, as those are the ticks on ES and NQ. So all my prices for the bracket and adjusted stoploss too. Can't check logs as I was using the TWS Workstation. Will try again with Gateway, to see if the logs give me any extra information.
Edit: The gateway (still) works without troubles. As described above. (I don't have this issue with the gateway, only workstation)
The log indicates that an order modification is attempted on an order that has already been canceled.
The log indicates that an order modification is attempted on an order that has already been canceled.
Sorry for re-opening. But that is the whole point. The order is not cancelled. It's the running StopLoss order that we're trying to change. But in doing so, we get that it can't find the parent (which we are not even touching) and then it says the StopLoss order is cancelled, which it is not.
Especially the part "Error 135, reqId 22: Can't find order with id = 20" is weird, because there is no action involving this OrderId.
Same issue. Has anyone solved this?
I fixed it by setting the parentID of the modification order to None:
stopLoss.parentId=None
I fixed it by setting the parentID of the modification order to None:
stopLoss.parentId=None
Thank you! This solved it for me as well!
Hi, I'm unable to modify existing orders (take profit/ stop loss in a bracket order) due to an error stating 'can’t find order with orderId = xx'. This xx refers to a parent order that was previously filled. It didn't happen everytime, in some cases it works straightaway. Here is my code snippet. Any clue of this?
parent_trd = ib.placeOrder(contract, bracket_order.parent)
tp_trd = ib.placeOrder(contract, bracket_order.takeProfit)
sl_trd = ib.placeOrder(contract, bracket_order.stopLoss)
After reach a certain pricesl_trd.order.auxPrice = new_price
sl_trd = ib.placeOrder(contract, sl_trd.order)