FIX API callbacks latency
FIX API callbacks latency
08 Dec 2023, 10:25
Hi all,
I noticed that sometimes I have a delay between “the order sent” and “the order was fulfilled”. I already had this situation several times for no reason. The last time the latency was exactly 13 seconds.
Please find the logs below and description of every step my system made on cTrader account 8880938 (IC Markets):
2023-12-05 16:14:49 UTC my system sent the Short Take Profit (close Sell position by market order) with the custom tag “11=SHORT_TP” and volume 6000.
2023-12-05 16:14:54 UTC after 5 seconds my system asked for the open positions, because it didn’t receive a callback from the Short Take Profit position (so the system doesn’t know if the Sell position was really closed) with the custom tag “710=check_close_short”. From the open positions report it is seen that the Sell position is still opened and was not closed. After that the system sent the “close Sell” order again with the custom tag “11=RESEND_SHORT_TP” and volume 6000.
2023-12-05 16:15:02 UTC with 13 seconds delay the “close Sell” position was finally closed with the custom tag “11=SHORT_TP” and volume 6000.
2023-12-05 16:15:04 UTC the “close Sell” position was closed again with the custom tag “11=RESEND_SHORT_TP” and volume 6000.
As a result I closed the Sell position and because of callback latency I reversed the position - opened Buy order with volume 6000 (and it was not planned).
I have 2 questions:
1) This time the latency was not that big and let's say it could be “manageable” somehow. Last time I had a latency of around 90 seconds. Is this problem coming from cTrader server or from IC Markets server (the broker I use)?
2) How can I technically avoid those big delays? If I understood correctly from the cTrader FIX API documentation, the system cannot recognise if the message sent by my system arrived to cTrader without problem or it was lost somewhere.
Let's imagine my system sent an order and it didn’t receive any callback. In a situation of latency my system just could wait - it is ok, but in case it is not a problem of latency and my sent message was lost, the system cannot wait, because the message was lost. So how can I recognise the situation that cTrader received the message and there is a latency and the situation that cTrader didn't receive the message and I need to send it again? How can I make it technically?
Many thanks in advance for your answer!
The logs itself:
2023-12-05 11:13:49,096 - root - INFO - SENT fix api trade: 8=FIX.4.49=9835=049=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=137952=20231205-16:13:49112=TEST10=018
2023-12-05 11:14:17,094 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=93|35=0|34=2753|49=cServer|50=TRADE|52=20231205-16:14:17.085|56=demo.icmarkets.8880938|57=TRADE|10=191|
2023-12-05 11:14:30,056 - root - INFO - RECEIVED fix api quote: 8=FIX.4.4|9=103|35=1|34=54997|49=cServer|50=QUOTE|52=20231205-16:14:30.048|56=demo.icmarkets.8880938|57=QUOTE|112=TEST|10=113|
2023-12-05 11:14:30,056 - root - INFO - RECEIVED fix api quote: 8=FIX.4.4|9=103|35=1|34=54997|49=cServer|50=QUOTE|52=20231205-16:14:30.048|56=demo.icmarkets.8880938|57=QUOTE|112=TEST|10=113|
2023-12-05 11:14:32,057 - root - INFO - SENT fix api quote: 8=FIX.4.49=9835=049=demo.icmarkets.888093856=cServer57=QUOTE50=QUOTE34=137152=20231205-16:14:32112=TEST10=063
2023-12-05 11:14:35,094 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=102|35=1|34=2754|49=cServer|50=TRADE|52=20231205-16:14:35.085|56=demo.icmarkets.8880938|57=TRADE|112=TEST|10=250|
2023-12-05 11:14:37,096 - root - INFO - SENT fix api trade: 8=FIX.4.49=9835=049=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138052=20231205-16:14:37112=TEST10=008
2023-12-05 11:14:49,573 - root - INFO - SENT fix api trade: 8=FIX.4.49=15935=D49=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138152=20231205-16:14:4911=SHORT_TP55=154=160=20231205-16:14:4938=600040=1721=38998465510=048
2023-12-05 11:14:54,575 - root - INFO - SENT fix api trade: 8=FIX.4.49=11235=AN49=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138252=20231205-16:14:54710=check_close_short10=081
2023-12-05 11:14:54,623 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=180|35=AP|34=2755|49=cServer|50=TRADE|52=20231205-16:14:54.615|56=demo.icmarkets.8880938|57=TRADE|55=1|710=check_close_short|721=389984655|727=2|728=0|730=1.08096|702=1|704=0|705=6000|10=207|8=FIX.4.4|9=182|35=AP|34=2756|49=cServer|50=TRADE|52=20231205-16:14:54.615|56=demo.icmarkets.8880938|57=TRADE|55=1|710=check_close_short|721=386746695|727=2|728=0|730=1.091695|702=1|704=24000|705=0|10=054|
2023-12-05 11:14:54,629 - root - INFO - SENT fix api trade: 8=FIX.4.49=16635=D49=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138352=20231205-16:14:5411=RESEND_SHORT_TP55=154=160=20231205-16:14:5438=600040=1721=38998465510=072
2023-12-05 11:14:57,899 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=210|35=8|34=2757|49=cServer|50=TRADE|52=20231205-16:14:57.890|56=demo.icmarkets.8880938|57=TRADE|11=SHORT_TP|14=0|37=639183274|38=6000|39=0|40=1|54=1|55=1|59=3|60=20231205-16:14:57.876|150=0|151=6000|721=389984655|10=110|
2023-12-05 11:15:00,947 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=217|35=8|34=2758|49=cServer|50=TRADE|52=20231205-16:15:00.938|56=demo.icmarkets.8880938|57=TRADE|11=RESEND_SHORT_TP|14=0|37=639183293|38=6000|39=0|40=1|54=1|55=1|59=3|60=20231205-16:15:00.929|150=0|151=6000|721=389984655|10=131|
2023-12-05 11:15:02,997 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=228|35=8|34=2759|49=cServer|50=TRADE|52=20231205-16:15:02.988|56=demo.icmarkets.8880938|57=TRADE|6=1.08028|11=SHORT_TP|14=6000|32=6000|37=639183274|38=6000|39=2|40=1|54=1|55=1|59=3|60=20231205-16:14:58.086|150=F|151=0|721=389984655|10=200|
2023-12-05 11:15:04,577 - root - INFO - SENT fix api trade: 8=FIX.4.49=11235=AN49=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138452=20231205-16:15:04710=check_close_short10=079
2023-12-05 11:15:04,625 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=182|35=AP|34=2760|49=cServer|50=TRADE|52=20231205-16:15:04.617|56=demo.icmarkets.8880938|57=TRADE|55=1|710=check_close_short|721=386746695|727=1|728=0|730=1.091695|702=1|704=24000|705=0|10=046|
2023-12-05 11:15:04,868 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=235|35=8|34=2761|49=cServer|50=TRADE|52=20231205-16:15:04.859|56=demo.icmarkets.8880938|57=TRADE|6=1.08029|11=RESEND_SHORT_TP|14=6000|32=6000|37=639183293|38=6000|39=2|40=1|54=1|55=1|59=3|60=20231205-16:15:01.209|150=F|151=0|721=389984655|10=210|
2023-12-05 11:15:14,578 - root - INFO - SENT fix api trade: 8=FIX.4.49=11235=AN49=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138552=20231205-16:15:14710=check_close_short10=081
2023-12-05 11:15:14,657 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=180|35=AP|34=2762|49=cServer|50=TRADE|52=20231205-16:15:14.648|56=demo.icmarkets.8880938|57=TRADE|55=1|710=check_close_short|721=389984655|727=2|728=0|730=1.08029|702=1|704=6000|705=0|10=204|8=FIX.4.4|9=182|35=AP|34=2763|49=cServer|50=TRADE|52=20231205-16:15:14.648|56=demo.icmarkets.8880938|57=TRADE|55=1|710=check_close_short|721=386746695|727=2|728=0|730=1.091695|702=1|704=24000|705=0|10=055|
2023-12-05 11:15:18,056 - root - INFO - RECEIVED fix api quote: 8=FIX.4.4|9=103|35=1|34=55099|49=cServer|50=QUOTE|52=20231205-16:15:18.048|56=demo.icmarkets.8880938|57=QUOTE|112=TEST|10=114|
2023-12-05 11:15:18,056 - root - INFO - RECEIVED fix api quote: 8=FIX.4.4|9=103|35=1|34=55099|49=cServer|50=QUOTE|52=20231205-16:15:18.048|56=demo.icmarkets.8880938|57=QUOTE|112=TEST|10=114|
2023-12-05 11:15:20,057 - root - INFO - SENT fix api quote: 8=FIX.4.49=9835=049=demo.icmarkets.888093856=cServer57=QUOTE50=QUOTE34=137252=20231205-16:15:20112=TEST10=062
2023-12-05 11:15:45,094 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=93|35=0|34=2764|49=cServer|50=TRADE|52=20231205-16:15:45.085|56=demo.icmarkets.8880938|57=TRADE|10=195|
2023-12-05 11:16:00,094 - root - INFO - RECEIVED fix api trade: 8=FIX.4.4|9=102|35=1|34=2765|49=cServer|50=TRADE|52=20231205-16:16:00.085|56=demo.icmarkets.8880938|57=TRADE|112=TEST|10=246|
2023-12-05 11:16:02,096 - root - INFO - SENT fix api trade: 8=FIX.4.49=9835=049=demo.icmarkets.888093856=cServer57=TRADE50=TRADE34=138652=20231205-16:16:02112=TEST10=008