SmartQuant Discussion
http://www.smartquant.com/forums/

IB Order Id
http://www.smartquant.com/forums/viewtopic.php?f=41&t=14591
Page 1 of 1

Author:  yan_ming [ Sat Jul 09, 2016 9:30 pm ]
Post subject:  IB Order Id

Hello, I am testing the OpenQuant2014 together with QuantRouter, which is connected to IB TWS. Once I sent out an Order, how can I get the Order Id that is used by IB to track the order status? Suppose I send out a few orders to TWS. Later when I get some error information, IB would return the Order Id associated with the error. How can I map this Order Id to some outstanding orders? Thanks a lot!

Author:  yan_ming [ Thu Jul 14, 2016 1:27 am ]
Post subject:  Re: IB Order Id

Does somebody care to comment on this question?

In case of multiple strategy solutions are running in parallel, the provider error message is broadcasted to all solutions and all strategies, even though the error is not caused by orders sent by some of the strategies. If we can have a mapping of SmartQuant Order Id to the IB Order Id, which is included in the provider error message, we would be able to figure out if the error message is targeted to a specific strategy and do some needed processing.

Or a general question, when a strategy receives provider error message, how does it know the message is for this strategy?

Thanks for any comments or suggestions!

Author:  Dr. Anton Fokin [ Sun Jul 17, 2016 9:16 pm ]
Post subject:  Re: IB Order Id

Hi,

in OQ2014 we have string Order.ProviderOrderId property for this, though in general you can not gain much from IB error message since it doesn't have corresponding order id field in the error message. You can see order id written in the text field of some IB error messages but I don't think it's a good idea to rip order id from text. Thus we trigger Strategy.OnProviderError for all strategies that use provider that generated this event.

Regards,
Anton

Author:  yan_ming [ Tue Jul 19, 2016 3:42 am ]
Post subject:  Re: IB Order Id

Hi Dr Fokin,

I checked the field Order.ProviderOrderId, but it is an empty string. Is there anything that we need to do to get it assigned properly? I am running the SmartQuant strategy through QuantRouter which is connected to IB TWS.

Thanks!

Author:  skuvv [ Tue Jul 19, 2016 11:43 am ]
Post subject:  Re: IB Order Id

yan_ming wrote:
Hi Dr Fokin,

I checked the field Order.ProviderOrderId, but it is an empty string. Is there anything that we need to do to get it assigned properly? I am running the SmartQuant strategy through QuantRouter which is connected to IB TWS.

Thanks!

Hello yan_ming,
you can download new version of OpenQuant2014, it contains changes with ProviderOrderId, now it will be filled when order comes from QuantRouter.
Additionally you can use property order.ClientID, it will be displayed as Order Ref. in IB TWS.

Author:  yan_ming [ Wed Jul 20, 2016 12:30 am ]
Post subject:  Re: IB Order Id

Hello, skuvv,

I tried the latest version, but I run into the following errors when I built the solution in Visual Studio environment. Could you take a look?

Thanks!

Attachments:
smartquant build error.PNG
smartquant build error.PNG [ 46.87 KiB | Viewed 9359 times ]

Author:  skuvv [ Mon Jul 25, 2016 1:13 pm ]
Post subject:  Re: IB Order Id

Hello yan_ming,
please try new version.

Author:  skuvv [ Wed Jul 27, 2016 12:45 pm ]
Post subject:  Re: IB Order Id

Fixed in today update.

Author:  yan_ming [ Fri Jul 29, 2016 12:47 am ]
Post subject:  Re: IB Order Id

Hello skuvv,
I tried with today's version, the same build issue still exists though. Could you take a look? Thanks!

Author:  skuvv [ Fri Jul 29, 2016 10:11 am ]
Post subject:  Re: IB Order Id

Can you please send me your solution with part of code which can reproduce this error?

Author:  yan_ming [ Fri Jul 29, 2016 10:49 pm ]
Post subject:  Re: IB Order Id

Hi skuvv,

I figured out what went wrong with my earlier build. In the project references, i added SmartQuant.*.dll from the OpenQuant2014 directory in order resolve some warning messages complaining it cannot create some provider type at program start. I removed all of them except SmartQuant.dll and SmartQuant.QR.dll. Now it builds fine. And I am able to see the field order.ProviderOrderId as well.

Thanks a lot for fixing this issue!

Author:  yan_ming [ Mon Aug 08, 2016 8:42 pm ]
Post subject:  Re: IB Order Id

Hi skuvv,

The feature works most of the time and the ProviderOrderId is assigned properly. However under the following scenario, it is not back annotated.

8/8/2016 10:21:00 Trial 0 10:21:00 AM Submit a SELL order (close) for JNUG 21 shares Order Id 0
8/8/2016 10:21:00 OnOderStatusChanged - OrderId - 0 - ProviderOrderId - - status Rejected
8/8/2016 10:21:00 OnOrderRejected - Order Id 0
8/8/2016 10:21:00 ProviderError - Error Id 111 - 201 - Order rejected - reason:The contract is not available for short sale
8/8/2016 10:21:00 OnOrderDone - OrderId - 0 - ProviderOrderId - - status Rejected

As you can see, the ProviderOrderId is empty when OnOrderStatusChanged, OnOrderRejected, or OnOrderDone is called. What is special in this case is that IB TWS rejects the order immediately once it is received.

Could somebody take a look and see what is happening?

Thanks!

Author:  skuvv [ Tue Aug 09, 2016 12:17 pm ]
Post subject:  Re: IB Order Id

Please look to the topic:
http://www.smartquant.com/forums/viewtopic.php?f=41&t=14604

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/