Profile Picture

OrderCancelled called, but orders not cancelled in IB

Posted By Zora 7 Years Ago
Message
Posted Wednesday February 17 2010
Hi guys, my setup: RE2 b14, IB as broker, live system on 1 min bars, trading stocks.

My problem: when I run a live system afterhours (4:30pm), immediately after a buy order is placed, the OrderCancelled() method is called with the information message "Warning: your order will not be placed at the exchange until 2010-02-18 09:30:00 US/Eastern". However, when I look in TWS, the order is still there - it never gets cancelled. My system continue running and shows no pending orders in the Live System tab. I thought that OrderCancelled() gets called only when an order is actually cancelled? Is this an error? You can try to reproduce this by simply placing a day order with IB after market close. Thank you!

Posted Thursday February 18 2010
So you place an order, is the buy order rejected because it is outside of the market hours or the cancel request is rejected? It sounds like you're saying the cancel is rejected, but why would IB accept a buy order outside of market hours and reject a cancellation?

Zora (2/17/2010)
Hi guys, my setup: RE2 b14, IB as broker, live system on 1 min bars, trading stocks.

My problem: when I run a live system afterhours (4:30pm), immediately after a buy order is placed, the OrderCancelled() method is called with the information message "Warning: your order will not be placed at the exchange until 2010-02-18 09:30:00 US/Eastern". However, when I look in TWS, the order is still there - it never gets cancelled. My system continue running and shows no pending orders in the Live System tab. I thought that OrderCancelled() gets called only when an order is actually cancelled? Is this an error? You can try to reproduce this by simply placing a day order with IB after market close. Thank you!

Posted Thursday February 18 2010
My buy order is being rejected (according to RE) because it is being placed after market close.

1). I place a buy order with OpenPosition()
2). Almost immediately, OrderCancelled() is invoked, with the message above
3). Switching to the TWS window, the buy order is alive and well - no sign of cancellation

Now, I can see why TWS would issue a warning in this scenario, but is RE mistaking it for a cancellation notification?

Edited: Thursday February 18 2010 by Zora
Posted Friday February 19 2010
OK, I believe I understand now, let me see if I can figure out the cause.
Posted Monday March 01 2010
The problem is that IB has a list of error codes, but the list isn't complete. If something isn't on the list, we don't know whether it's a warning we should ignore or an error which means the order should be cancelled.

If you can tell us what the error code is, I can modify the TWS plugin to handle it correctly. I've modified the TWS plugin to include the error code in the message when an order is cancelled, so that you will be able to see this information.

Thanks,
Daniel
Posted Saturday March 06 2010
Awesome, I'll gladly do that if you tell me where to find the updated TWS plugin.
Posted Sunday March 07 2010
I've just released the updated TWS plugin source. See this post for the download link.

Thanks,
Daniel
Posted Friday April 23 2010
Daniel,

I have updated from the repository as of yesterday and rebuilt the TWSPlugin; however, the same problem is occurring, i.e., an order placed during non-RTH in cancelled in RightEdge (live system does not register trades) but still active in TWS. The following is the error message:

Order cancelled: IB error/warning code 399: Order Message: Warning: your order will not be placed at the exchange until 2010-04-22 09:30:00 US/Eastern   STLD   Symbol Script   4/22/2010 2:12:08 AM

Please advise.

Thanks, Duane
Posted Monday April 26 2010
We didn't know what error code was associated with this warning, so we made the change to include the error code in the message. Now we know that the error code was 399 thanks to your post. Error code 399 is listed as "Order message error" in the TWS error code list, so there are probably cases where 399 means that the order was cancelled. So I've added code that will consider it a warning if the error code is 399 and the error message starts with ""Order Message: Warning: your order will not be placed at the exchange until".

I've updated the code on github so if you pull it down again and rebuild this should be fixed. Let us know if it's not or you run into any other issues.

Thanks,
Daniel
Posted Tuesday April 27 2010
I will test tomorrow (tested today but no buys). If I don't get back, everything is working. I really appreciate you looking into this as quickly as you did.

Thanks for the great support.

Duane


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems