SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Jun 19, 2018 7:05 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject: Re: Wrong order fill
PostPosted: Fri Nov 21, 2014 7:19 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Alexei,

more info.
i run two TWSs on two different PCs: one tws on each PC

MGI was generated on PC1 from OQ
INVE was generated on PC2

according to logs both MGI and INVE orders have same order id = 1704. seems it's the problem.

i talked to IB support, i thought that it's their problem as TWS has two orders with same order id, but according to them it's ok:

Raymund: order id to use if you are only monitoring a single session of the TWS. If you also monitoring orders from other sessions, then you also need to examine the permId information
Raymund: please note that order id and client id are local identifier between the API and TWS
Raymund: on the same computer
Raymund: or the same session
Raymund: but if you are monitoring other orders from other session, you need to include the permId as well

i've checked permID - different for these orders. seems it's global unique order id


please let me know what you investigated and how we can solve this problem.

thanks,
Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Fri Nov 21, 2014 7:29 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hmm... You did not tell about it before. It may be a reason of the order's mixing...
In a case of two or more clients to the same TWS (or different TWS but with the same login)
you should use the different ClientId value in IB plugin properties.

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Fri Nov 21, 2014 7:49 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
sorry i investigated that order id are same recently and decided that 2 tws can be a reason.

sure, i use different clientid.
PC1 (where OQ is) clientid = 1
PC clientid = 57

i use different IB logins on different PCs. IB allows to create several logins/users for same account, so we've created and use different logins on each TWS/PC


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Mon Nov 24, 2014 12:08 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
hi Alexei,
any update?
thanks
Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Mon Nov 24, 2014 3:45 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

No, I have not found a reason of the problem yet.

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Mon Nov 24, 2014 5:08 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Alexei, but isn't the same order id (1704) a reason?
Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Mon Nov 24, 2014 11:17 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Ivan,

In the logs, I see three trades for the order number 1704 - for 100, 100 and 300.
(like order manager window shows)
Also, in the last report IB tells that CumQty is 500.
May be you have changed an order outside OQ?

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Tue Nov 25, 2014 4:21 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Hi Alexei,

no, it's because not only price but also Qty is incorrect,

I sent Buy 500 shares for INVE from another TWS (from another PC)
Problem is that the ID of the INVE order also = 1704 - same ID as for MGI stop order.

So TWS sent (I suppose) notification to OQ that order with ID 1704 filled with 500 shares. notification was about INVE order but OQ processed it as MGI order because order ID is same.

Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Tue Nov 25, 2014 6:13 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Ivan,

It is new (and strange) for me that the different client ids are not enought to separate API clients.
Of course, the plugin will operate incorrectly if it receives the messages for another client.
At the moment, there is no way to resolve this issue, but you could use QuantRouter as a single IB client,
and send the orders from the different OQs through it.

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Tue Nov 25, 2014 7:21 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Alexei,

seems it's ok for IB to have same order IDs (in case with 2+ running TWS) - seems ID is unique inside one clientID. But for now the main question is how to recognize these IDs.
possible need to check uniqueness not only by OrderID but OrderID+ClientID or use permID... or smth else, you better know.

please recheck what I've wrote several posts ago.
Raymund is API support/engineer or IB
__________
i talked to IB support, i thought that it's their problem as TWS has two orders with same order id, but according to them it's ok:

Raymund: order id to use if you are only monitoring a single session of the TWS. If you also monitoring orders from other sessions, then you also need to examine the permId information
Raymund: please note that order id and client id are local identifier between the API and TWS
Raymund: on the same computer
Raymund: or the same session
Raymund: but if you are monitoring other orders from other session, you need to include the permId as well

i've checked permID - different for these orders. seems it's global unique order id


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Tue Nov 25, 2014 7:54 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Ivan,

I believe that you don't use the same IB credentials in different TWS and don't use the same client ids in OQs,
so I don't understand why the one API client receives the messages from another connection.
Also, you do not monitor the orders from other sessions (client id is 0).

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Thu Nov 27, 2014 3:10 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Hi Alexei,

right, i use different IB credentials in different PCs/TWSs.

>>so I don't understand why the one API client receives the messages from another connection.
i suppose that TWS sends all events to all clients but client filters out events from other clients.
as far as i remember, when i developed my own app (client to TWS) it was so - i received all notifications and filtered them by client ID.
seems OQ doesnt use client id for filtering. it would work if OQ monitors not only order id but orderid+clientid.
other way is to monitor permID is it's really unique number (it's rather big)

as far as i see - this situation is OK from IB side. but OQ should handle this correctly.

how we can solve this?

please let me know.
Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Thu Nov 27, 2014 6:46 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi Ivan,
Quote:
i suppose that TWS sends all events to all clients but client filters out events from other clients.

No, this is not the case. Why the client A should see the orders from client B?
TWS separates events by client id and sends all events to the master client only (id is zero)

_________________
SmartQuant Development Team


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Thu Nov 27, 2014 7:27 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
Anyway it does so (at least latest version of TWS) - you can check this.
I've checked just now on my apps: app is running on clientid = 58 and it received all orders generated by all clients and also the orders that was created manually in TWS (with no API/client)
Ivan


Top
 Profile  
 
 Post subject: Re: Wrong order fill
PostPosted: Thu Nov 27, 2014 7:31 pm 
Offline

Joined: Tue May 01, 2012 6:46 pm
Posts: 97
here is the example:
http://grabilla.com/04b1b-8525432a-c6a5 ... b7ea51.png
right side window "Summary" is my app with clientid = 55 (you can see this in settings)

As you see it receives all orders from TWS.
90% these orders was created by OQ, 10% - manually in TWS. there are no orders created by my app (clientid=55)

here is the my TWS version info:
http://grabilla.com/04b1b-e4522b04-ed87 ... 05e03b.png

please check this on your side.
thanks
Ivan


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 31 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 3 hours


Who is online

Users browsing this forum: Google [Bot] and 7 guests


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