Huge delay in Sent and Received FIX Messages

Created at 28 Nov 2018, 18:10
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
NE

netread2004

Joined 26.12.2017

Huge delay in Sent and Received FIX Messages
28 Nov 2018, 18:10


I am running robot where Robot sends FIX messages to place Stop Order with certain ClOrdID 11=<ClOrdID> and send Order Status Check message 35=H to get the status of this Stop Order. To know the status Robot waits for 35=8 with 11=<sameClOrdID> same ClOrdID as sent message.

This Robot also Trails the Stop Order placed as mentioned above. Trail is implemented by Cancel Order + Place New Stop Order).  This invloves repeatedly placing new Stop Orders with new ClOrdIDs and it involves checking Order status by sending 35=H with ClOrdIDs and receivien 35=8 with the same ClOrdID.

In this process what I obevered is that when I start my Robot these messages 35=8 in response to 35=H are received in single Send/Receive transaction. This trailing Stop order mechanism I use for both stand alone Stop Order as well as STOPLOSS stop order to close a position. During this process the StopOrder converts to Position and Postion closes with closing of another stop Order that is used as STOPLOSS. In the beginging when I start my Robot I get 35=H->35=8 with same ClOrdID in single Send/Receive transaction however after closing few Positions this response changes and I do not get 35=H->35=8 response in single transaction but I have to wait for couple of transaction. As the number of closing postions increases the response gets delayed by several such transaction. My Robot decision making is based on the responses 35=8 therefore this introduces delay in decision making and cosequenly delays placing stop order as STOPLOSS to given Position.  As I observed, this happens because - when I send 35=H I start receivieng 35=8 for all previous closed StopOrder/Positions and eventually I get the required 35=8 with the same ClOrdID.

My question is - how can I get these responses in single transaction? Am I missing any basic setting for FIX environment due to lack of which this is happening? If not, is there any way where I can make sure that always there is 35=H->35=8 in single Send/Receive Transaction? Is there any way I can Reset the TRADE server and remove all previous StopLoss/Positions data base in FIX server? 

Please let me know what can be done in this situation to resolve this issue.

 


@netread2004
Replies

... Deleted by UFO ...

PanagiotisCharalampous
29 Nov 2018, 10:00

Hi netread2004,

Since I do not have any code I can only assume what is happening. In general, you should not program your application in a transactional way. Since FIX API messages are streamed and they might not have a one to one correspondence to the messages sent, you should have a listener function that constantly reads and parses messages received via the stream, no matter how many messages are sent. This way you will receive your messages as soon as they arrive and not when your application decides to read a message from the stream. 

Also you can consider using 35=AF which returns the status of all orders instead of asking for them one by one.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
29 Nov 2018, 18:11

Thanks for your reply.

I am using simple parsing function in OnTick process and that does the parsing of all received messages.

Is there any other way that can do this parsing more frequent than each Tick?  

I am now parsing all received messages irrespective of the type of message I send. Is it not same as listener function?

Regarding 35=AF, I do not see this function in FIX API Sample code. I am trying to incorporate this function in my code but I have few questions on Tag 584 and 585.  What should be the value of 584? Is it the same as ClOrdID ( the value of 11)? What should be the value of 585? Should it be 1 (Status for Orders for a Secuirty)? 

Please let me know.

 


@netread2004

PanagiotisCharalampous
30 Nov 2018, 10:05

Hi netread2004,

You can consider using Timer. For 35=AF, you can check our Rules of Engagement. 584 is just an ID so that you can identify the incoming message. You can use whatever you want. 585 should always be 7.

Best Regards,

Panagiotis


@PanagiotisCharalampous

netread2004
30 Nov 2018, 21:26

Panagiotis,

Thanks for your suggestions.

35=AF works great! I am able to get the responses for particualar 584=ID  quickly unlike what used to happen with 35=H.

Also, I am now using 1 second timer to parse received messages. I can not go less than 1 second becasue Timer allows only interger type input parameter. Is there any technique one can use to invoke events like timer with time interval less than 1 sec?

 

.

 

 


@netread2004

PanagiotisCharalampous
03 Dec 2018, 10:34

Hi netread2004,

You can use the overload that uses a TimeSpan parameter for the Start function.

Best Regards,

Panagiotis


@PanagiotisCharalampous