Profile Picture

Unable to cancel ProfitTarget order:Order not found exception

Posted By alpha23 5 Years Ago

Unable to cancel ProfitTarget order:Order not found exception

Message
Posted Wednesday December 12 2012
I received the following exception today:

Unable to cancel ProfitTarget order:Order not found: 49045
at RightEdge.Common.PositionManager.UpdateSpecialOrder(PositionData pos, TradeType type)
at RightEdge.Common.PositionManager.UpdateSpecialOrders(PositionData pos)
at RightEdge.Common.PositionManager.PositionOrderFilled(PositionData pos, PositionState posState, BrokerOrder order, Fill fill, TradeType tradeType, String description, Boolean sendUpdate)
at RightEdge.Common.PositionManager.OnOrderFilled(BrokerOrder order, Fill fill, PositionData pos, PositionState posState, TradeOrder tradeOrder)
at RightEdge.Common.PositionManager.broker_OrderUpdated(BrokerOrder brokerOrder, Fill fill, String information)
at RightEdge.Shared.CallbackStub.DoCallback()

Here is the TWS log related to this order:

12/12/2012 14:01   NVDA   49045   79   SubmitOrder   49045: Limit Cover NVDA @ 12.52 0/600 - Submitted
12/12/2012 14:01   NVDA   49045   79   OrderStatusInactive   Order status updated
12/12/2012 14:01   NVDA   49045   79   IB error/warning   201: Order rejected - reason:The exchange is closed.
12/12/2012 14:01   NVDA   49045   79   OrderStatusInactive   Order status updated

Any thoughts on how to fix?

Thanks, Duane
Posted Monday December 24 2012
It looks like what happened here is that IB rejected the order, and RightEdge tried to cancel the order between the time when the rejection was processed by the TWS plugin and when it was processed by RightEdge. So RightEdge thought the order was still active, but the TWS plugin had no record of it (since it had been cancelled/rejected). So when RightEdge tried to cancel the order, the TWS plugin returned an error, which caused RightEdge to throw the exception.

The TWS plugin already has logic to handle the similar situation where RightEdge tries to cancel an order that has already been filled. It keeps track of the order IDs that have been recently filled, and if an order was recently filled it won't return an error if RightEdge tries to cancel it. I've modified this logic so it will now also keep track of cancelled orders in this way, which should prevent this issue in the future. The updated code is attached. I renamed the FilledOrders class (and corresponding source file) to OrderHistory since it now keeps track of both filled and cancelled orders.

Thanks,
Daniel

EDIT: The version I uploaded here was the wrong version, see below for the correct one.
Posted Wednesday December 26 2012
Hi RE,

We tried to compile this code and got stuck on this part of the code  : using REOrderStatus = RightEdge.Common.OrderStatus;
with error:

The type or namespace name 'OrderStatus' does not exist in the namespace 'RightEdge.Common' (are you missing an assembly reference?) .

Maybe common.dll is not yet up to date?

Posted Wednesday December 26 2012
Oops, I attached the wrong code (it was the version from "vNext" of RightEdge). The version attached here should be the right one.

Thanks,
Daniel

Attachments
TWSCSharpPlugin2012_12_26.zip (155 views, 28.00 KB)
neo
Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)
Posted Tuesday October 15 2013
is the attached twsplugin newer than build 49 sample? because it seems build 49's tws plugin cannot build because of missing OrderHistory.cs file.
Posted Sunday October 20 2013
The version in build 49 is more recent, but the OrderHistory.cs file is missing. Sorry about that- when I added it to the source I missed adding it to the RightEdge installer. You can find the right file attached here.

Thanks,
Daniel

Attachments
OrderHistory.cs (150 views, 1.00 KB)
neo
Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)Supreme Being (4,025 reputation)
Posted Sunday December 15 2013
Thanks, this saved my day.

One more question, would there be an effort try to keep KRS.ATS.IBNet updated? Since krs.ats.ibnet is now available on nuget, however, if I try to use the nuget version (assuming it's the "latest"), the plugin will have a few build error. Perhaps it has broken its backward compatibility.

Edited: Sunday December 15 2013 by neoaries


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems