SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Dec 16, 2019 9:14 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: IB Order Id
PostPosted: Sat Jul 09, 2016 9:30 pm 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Thu Jul 14, 2016 1:27 am 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Sun Jul 17, 2016 9:16 pm 
Offline

Joined: Tue Aug 05, 2003 3:43 pm
Posts: 6816
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


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Tue Jul 19, 2016 3:42 am 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Tue Jul 19, 2016 11:43 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
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.


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Wed Jul 20, 2016 12:30 am 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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 8729 times ]
Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Mon Jul 25, 2016 1:13 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Hello yan_ming,
please try new version.


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Wed Jul 27, 2016 12:45 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Fixed in today update.


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Fri Jul 29, 2016 12:47 am 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
Hello skuvv,
I tried with today's version, the same build issue still exists though. Could you take a look? Thanks!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Fri Jul 29, 2016 10:11 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Can you please send me your solution with part of code which can reproduce this error?


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Fri Jul 29, 2016 10:49 pm 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Mon Aug 08, 2016 8:42 pm 
Offline

Joined: Mon May 02, 2016 5:11 am
Posts: 19
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!


Top
 Profile  
 
 Post subject: Re: IB Order Id
PostPosted: Tue Aug 09, 2016 12:17 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 562
Please look to the topic:
http://www.smartquant.com/forums/viewtopic.php?f=41&t=14604


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group