Topics
19 Nov 2018, 14:48
 1319
 2
Replies

netread2004
20 Feb 2019, 10:52

Few questions :

1) How do  I associate account IDs with account number?

2)All I want is to login to my account number and send /receive FIX message for trading my cTrader account. I am not sure these accoun IDs will help in doing that. Looks like things are confusing and not sure where to find these account IDs.

3)What do you mean by Trader Login detials if that means trader account number and password then your sample Open API does not mention anywhere Trade account number and password where I can substitute my account info and start runing to place orders. Not sure what is achieved by using Account IDs as opposed to Account number.

4)Is there any document which mentions simple flow on how to use of Open API to trade cTrader account with FIX messages?

Thanks

 


@netread2004

netread2004
20 Feb 2019, 02:27

Tried to get new tokens several time and repeating this same thing again and agian I get the same list of accounts, I am not sure where these account numbers are coming. They are not mine. Can you please investigate this? I can send you list of accounts to your email to investigate further on this .

Please let me know.,

 


@netread2004

netread2004
19 Feb 2019, 10:19

Yes, I did. 

This is what  I have done to get new token

Application -> PlayGround  select scope Accounts
Get Toekn -> I see the list of my accounts
Clicked on "Allow Acess" with all accounts selected with checkmarks
This took me back to accountinfo page . I copied access_token and used in OPEN API Sample program in _token =.

_apiHost = "demo.ctraderapi.com";, _apiPort = 5035  is this correct?

I am following everything mentioned in the document.  Not sure where these random account numbers I am getting.

Any suggestions on how to fix this issue?

 


@netread2004

netread2004
19 Feb 2019, 06:09

I am getting both Live as well as Demo account numbers and none of them belong to me.

As I mentioned in my earleir message I used _apiHost = "demo.ctraderapi.com";, _apiPort = 5035

So, I should get the list of all Demo account linked to my cTID. But I am getting the list of accounts those are not linked to my cTID at all.

I am not sure where these account numbers are coming from.

Can you please suggest how I can get the account number linked ot my cTID and what could be the possible reason I am getting these random account numbers?

 


@netread2004

netread2004
18 Feb 2019, 12:53

Thanks.

It took some time to get all account numbers.

However, when I see the account number I got from OPEN API they do not match with cTrader Account nmber those are linked to my CTId.

I assume the list I get from OpenAPI is the list of cTrader account that are linked to my cTID and the same account that I can see in Apps-> PlayGround ->Account Info menu,

Could you please let me know why there is a mismatch like this?

Thanks again.

 

 

 

 


@netread2004

netread2004
01 Feb 2019, 06:16

Thank you very much for your help in getting very good insight in working of FIX message.


@netread2004

netread2004
31 Jan 2019, 17:49

I totally agree with you on what you said "If you are sending a message with a ClOrdID (1517158681)  but you receive a response with another ClOrdID (1746432918) then probably the server is still responding to messages sent before (1746432918 must have been sent before 1517158681). "

Having said this can you tell me what you mean by "wait until 35=8 arrives for 1517158681"? 

Looks like there is some way to know what message I am receiving without sending any additional message to server from my computer.

That is server will , on its own, start sending messages and somehow I have to look for what message server is sending.

Is there any method by which I can receive message from server without sending any message to server?

As I can see from the code from Sample application following call is the only way to receive message from server:

txtMessageReceived_Text = SendTradeMessage(message);

But in order to receive message from server I have to send some "message" using above function call

I don't see any method that will help me in waiting for receiving the required message without sending QUERY message to server.

Can you tell me how I can "wait until 35=8 arrives for 1517158681"? 


@netread2004

netread2004
31 Jan 2019, 16:11

Sorry for the typo in ClOrdID in several places. Here is the correct message:

 

That is what exactly I did.

Here is the part of messages that I have attached in the begingin of this thread.

Message 1 ---- 0 00:37:20.970 GBPUSD,M1: SendText : 8=FIX.4.4 9=147 35=D 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=859 52=20190125-08:37:20 11=1517158681 55=2 54=2 60=20190125-08:37:20 38=1000 40=1 59=1 10=223 

The above message is 35=D that I sent with ClOrdID 11=1517158681 .  I received the following message in response to above message:

Message 2 --- 0 00:37:20.970 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=214 35=8 34=28 49=cServer 50=TRADE 52=20190125-08:35:57.332 56=icmarkets.3421704 57=TRADE2 6=1.30905 11=1746432918 14=1000 37=91299814 38=1000 39=2 40=1 54=2 55=2 59=3 60=20190125-08:35:57.295 150=F 151=0 721=53892568 10=070 

The above message 35=8 I received in response to 35=D I sent. As you can see this 35=8 does NOT correspond to 11=1517158681 the original 35=D clOrdID. So, as you suggested I received 35=8 and then I sent 35=AN for the same ClOrdID (710=1517158681) as it was sent in first 35=D message. 35=AN is as follows:

Message 3 --- 0 00:37:21.071 GBPUSD,M1: SendText : 8=FIX.4.4 9=100 35=AN 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=860 52=20190125-08:37:20 710=1517158681 10=115 

Following is the message received in response to 35=AN with ClOrdID  710=1517158681.  Following is 35=AP but it is not for ClOrdID 710=1517158681. Following 35=AP is for some other ClOrdID 710=1746432918 that means 721 is not corresponding to market order sent in 35=D with ClOrdrID 11=1746432918.

Message 4 --- 0 00:37:21.071 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=166 35=AP 34=29 49=cServer 50=TRADE 52=20190125-08:35:57.427 56=icmarkets.3421704 57=TRADE2 55=2 710=1746432918 721=53892568 727=1 728=0 730=1.30905 702=1 704=0 705=1000 10=133 

 

Now, I did not receive 35=AP corresponding to ClOrdID  710=1517158681 and therefore I sent another 35=AN and received 35=AP but as you can see from the sequence of messages in the begining of this thread this 35=AP does not correspond to ClOrdID 710=1517158681; therefore I have to send 35=AN repeatedly until I get either 35=8 or 35=AP that corresponds to original ClOrdID 1517158681. AS you can see it took so many messages to get the the correct 721 correspond to the ClOrID 1517158681. the last message in this case 35=8 is as follows:

0 00:37:22.466 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=204 35=8 34=42 49=cServer 50=TRADE 52=20190125-08:37:19.637 56=icmarkets.3421704 57=TRADE2 11=1517158681 14=0 37=91299889 38=1000 39=0 40=1 54=2 55=2 59=3 60=20190125-08:37:19.600 150=0 151=1000 721=53892607 10=087 

The correct 721 is 53892607 and other 721 I received in other messages are not the correct 721 values.

Does this clarify why I am sending multiple 35=AN message? Please let me know.

 


@netread2004

netread2004
31 Jan 2019, 16:02

RE:

netread2004 said:

That is what exactly I did.

Here is the part of messages that I have attached in the begingin of this thread.

Message 1 ---- 0 00:37:20.970 GBPUSD,M1: SendText : 8=FIX.4.4 9=147 35=D 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=859 52=20190125-08:37:20 11=1517158681 55=2 54=2 60=20190125-08:37:20 38=1000 40=1 59=1 10=223 

The above message is 35=D that I sent with ClOrdID 11=1517158681 .  I received the following message in response to above message:

Message 2 --- 0 00:37:20.970 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=214 35=8 34=28 49=cServer 50=TRADE 52=20190125-08:35:57.332 56=icmarkets.3421704 57=TRADE2 6=1.30905 11=1746432918 14=1000 37=91299814 38=1000 39=2 40=1 54=2 55=2 59=3 60=20190125-08:35:57.295 150=F 151=0 721=53892568 10=070 

The above message 35=8 I received in response to 35=D I sent. As you can see this 35=8 does NOT correspond to 11=1517158681 the original 35=D clOrdID. So, as you suggested I received 35=8 and then I sent 35=AN for the same ClOrdID (710=1517158681) as it was sent in first 35=D message. 35=AN is as follows:

Message 3 --- 0 00:37:21.071 GBPUSD,M1: SendText : 8=FIX.4.4 9=100 35=AN 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=860 52=20190125-08:37:20 710=1517158681 10=115 

Following is the message received in response to 35=AN with ClOrdID  710=1517158681.  Following is 35=AP but it is not for ClOrdID 710=1517158681. Following 35=AP is for some other ClOrdID 710=1746432918 that means 721 is not corresponding to market order sent in 35=D with ClOrdrID 11=1746432918.

Message 4 --- 0 00:37:21.071 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=166 35=AP 34=29 49=cServer 50=TRADE 52=20190125-08:35:57.427 56=icmarkets.3421704 57=TRADE2 55=2 710=1746432918 721=53892568 727=1 728=0 730=1.30905 702=1 704=0 705=1000 10=133 

 

Now, I did not receive 35=AP corresponding to ClOrdID  710=1746432918 and therefore I sent another 35=AN and received 35=AP but as you can see from the sequence of messages in the begining of this thread this 35=AP does not correspond to ClOrdID 710=1746432918; therefore I have to send 35=AN repeatedly until I get either 35=8 or 35=AP that corresponds to original ClOrdID 1746432918.  AS you can see it took so many messages to get the the correct 721 correspond to the ClOrID 1746432918. the last message is as follows:

0 00:37:22.466 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=204 35=8 34=42 49=cServer 50=TRADE 52=20190125-08:37:19.637 56=icmarkets.3421704 57=TRADE2 11=1517158681 14=0 37=91299889 38=1000 39=0 40=1 54=2 55=2 59=3 60=20190125-08:37:19.600 150=0 151=1000 721=53892607 10=087 

The correct 721 is 53892607 and other 721 I received in other messages are not the correct 721 values.

Does this clarify why I am sending multiple 35=AN message? Please let me know.

 

correction in part of above message instead of "order sent in 35=D with ClOrdrID 11=1746432918." please read it as "order sent in 35=D with ClOrdrID 11=1517158681."


@netread2004

netread2004
31 Jan 2019, 15:58

That is what exactly I did.

Here is the part of messages that I have attached in the begingin of this thread.

Message 1 ---- 0 00:37:20.970 GBPUSD,M1: SendText : 8=FIX.4.4 9=147 35=D 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=859 52=20190125-08:37:20 11=1517158681 55=2 54=2 60=20190125-08:37:20 38=1000 40=1 59=1 10=223 

The above message is 35=D that I sent with ClOrdID 11=1517158681 .  I received the following message in response to above message:

Message 2 --- 0 00:37:20.970 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=214 35=8 34=28 49=cServer 50=TRADE 52=20190125-08:35:57.332 56=icmarkets.3421704 57=TRADE2 6=1.30905 11=1746432918 14=1000 37=91299814 38=1000 39=2 40=1 54=2 55=2 59=3 60=20190125-08:35:57.295 150=F 151=0 721=53892568 10=070 

The above message 35=8 I received in response to 35=D I sent. As you can see this 35=8 does NOT correspond to 11=1517158681 the original 35=D clOrdID. So, as you suggested I received 35=8 and then I sent 35=AN for the same ClOrdID (710=1517158681) as it was sent in first 35=D message. 35=AN is as follows:

Message 3 --- 0 00:37:21.071 GBPUSD,M1: SendText : 8=FIX.4.4 9=100 35=AN 49=icmarkets.3421704 56=cServer 57=TRADE 50=TRADE2 34=860 52=20190125-08:37:20 710=1517158681 10=115 

Following is the message received in response to 35=AN with ClOrdID  710=1517158681.  Following is 35=AP but it is not for ClOrdID 710=1517158681. Following 35=AP is for some other ClOrdID 710=1746432918 that means 721 is not corresponding to market order sent in 35=D with ClOrdrID 11=1746432918.

Message 4 --- 0 00:37:21.071 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=166 35=AP 34=29 49=cServer 50=TRADE 52=20190125-08:35:57.427 56=icmarkets.3421704 57=TRADE2 55=2 710=1746432918 721=53892568 727=1 728=0 730=1.30905 702=1 704=0 705=1000 10=133 

 

Now, I did not receive 35=AP corresponding to ClOrdID  710=1746432918 and therefore I sent another 35=AN and received 35=AP but as you can see from the sequence of messages in the begining of this thread this 35=AP does not correspond to ClOrdID 710=1746432918; therefore I have to send 35=AN repeatedly until I get either 35=8 or 35=AP that corresponds to original ClOrdID 1746432918.  AS you can see it took so many messages to get the the correct 721 correspond to the ClOrID 1746432918. the last message is as follows:

0 00:37:22.466 GBPUSD,M1: ReceivedText : 8=FIX.4.4 9=204 35=8 34=42 49=cServer 50=TRADE 52=20190125-08:37:19.637 56=icmarkets.3421704 57=TRADE2 11=1517158681 14=0 37=91299889 38=1000 39=0 40=1 54=2 55=2 59=3 60=20190125-08:37:19.600 150=0 151=1000 721=53892607 10=087 

The correct 721 is 53892607 and other 721 I received in other messages are not the correct 721 values.

Does this clarify why I am sending multiple 35=AN message? Please let me know.

 


@netread2004

netread2004
31 Jan 2019, 15:18

Ok. Let me understand this first.

Following is the part of code for sending 35=AN from your Sample Application:

---------------------------

        private void RequestForPositions(string posID)
        {
            ClearText();
            var message = _messageConstructor.RequestForPositions(MessageConstructor.SessionQualifier.TRADE, _messageSequenceNumberT, posID);
            _testRequestID++;
            txtMessageSend_Text = message;
            txtMessageReceived_Text = SendTradeMessage(message);
            if (printWholeFixMsg)
                printSendReceive();
            if (deCryptEn)
                deCryptMessage(txtMessageSend_Text, txtMessageReceived_Text);
        }

--------------------

When I call RequestForPositions(ClOrdID) the message 35=AN  ( string varaible message in above code) is sent to server and also it receives some response which is read in variable txtMessageReceived_Text  from server .

I have just added print option and decode option "deCryptEn" to this code otherwise this is same code as it is in Sample Application.

When I send 35=AN using above routine I receve some message back from server and it is NOT neccessarily 35=AP at all. If I dont receive 35=AP then I am not going to receive this If I don't send another 35=AN and that is the reason I send it repeatedly until I get 35=AP for corresponding ClOrID.

How do I get 35=AP without sending any message? If I am just sending 35=AN once and wait for 35=AP without sending any new message how am I going ot get it? I think there is some issue here in my basic understanding and I trying to understand fully. 

Please through some light on this. I would greatly appreciate.

 


@netread2004

netread2004
31 Jan 2019, 14:52

I send an order first and then send 35=AN to get 35=AP for corresponding CLOrderID to find out 721=???.

Here is the squence of FIX messages 

1. 35=D with certain ClOrderID -- to place market order.

2. I send 35=AN to request position status and I look for 35=AP for the same ClOrdID (that is 710==) to get 721=??

3. I repeat step 2 until I get 35=AP for corresponding ClOrdID to get 721=?? value.

I repeat step 2 every 100ms so that I can get the response 35=AP fast. It is part of Listener process.

Does this make any sense?

 


@netread2004

netread2004
31 Jan 2019, 13:45

I used sample application code in my program after removing GUI part of it and made it automatic. My system works automatically, that is, it keeps sendinding 35=D and keep checking for 721=?? in 35=AP by sending 35=AN. I am sending these FIX messages using same code as in your sample application I just removed GUI part of it and made it automatic.

This can not be reproduced in sample application becasue sample application is manual application through GUI.

I don't think you can reproduce this by sending just one message through GUI.

This is what happens - when I send very first 35=AN message after 35=D for market order you might see the response very fast and I could see that with this example.  It is in few hundred milliseconds, But, as I keep sending automatically more and more 35=D, the response get slower and slower. Since this program I am using for sending messages automatically after say 10 such 35=D message responses get delayed more and more and delay become in the magnitide more than 10 seconds. I can plot a graph on this I can send you.

So, this is real issue and I don't think you can reproduce with sample application you have just by clicking buttons manually. This must be reproduced by running program automatically and obsverve the delay in respone to 35=AN that gets accumulated as number of 35=D increase.

Please can you comment on the general method I am using to get 721=*** for my market order? Is it valid way of doing it or is there any tag I should use to get these messages? I would appreciate if you could comment on this.

Thanks

 

 

 

 


@netread2004

netread2004
31 Jan 2019, 12:45

Any feedback on this please?


@netread2004

netread2004
25 Jan 2019, 11:23

To add one thing to this is - I observed that as time passes  this delay gets worse as more and more FIX mesages are sent to place Market orders and in one case I see that I recevied 721= value after 15 seconds. Am I doing something wrong here?

Please comment on this.

Thanks

 


@netread2004

netread2004
17 Dec 2018, 12:48

Yup, 

I changed my VPS local time appropriatly and now it is working.

Thanks you very much.

 


@netread2004

netread2004
11 Dec 2018, 14:47

Here is the first 35=W (34=2) message and 35=X (34=3) following that.

-----------------------------------------------------------------------------------------------

 

2018.12.11 04:37:00.012 GBPUSDi,M1: ReceivedText : 8=FIX.4.4 9=306 35=X 34=3 49=cServer 50=QUOTE 52=20181211-12:36:18.147 56=icmarkets.3394382 57=TRADE2 268=5 279=0 269=1 278=156431374 55=2 270=1.26191 271=5000000 279=0 269=1 278=156431375 55=2 270=1.2619 271=3000000 279=0 269=1 278=156431372 55=2 270=1.26189 271=1000000 279=2 278=156430419 55=2 279=2 278=156430416 55=2 10=050 

2018.12.11 04:37:00.012 GBPUSDi,M1: SendText : 8=FIX.4.4 9=142 35=V 49=icmarkets.3394382 56=cServer 57=QUOTE 50=TRADE2 34=3 52=20181211-12:36:59 262=36147899 263=1 264=0 265=1 267=2 269=0 269=1 146=1 55=2 10=216 

2018.12.11 04:36:17.652  GBPUSDi,M1: ReceivedText : 8=FIX.4.4 9=444 35=W 34=2 49=cServer 50=QUOTE 52=20181211-12:36:17.682 56=icmarkets.3394382 57=TRADE2 55=2 268=8 269=1 270=1.26188 271=1000000 278=156430419 269=1 270=1.2619 271=8000000 278=156430416 269=1 270=1.26184 271=100000 278=156430417 269=1 270=1.26185 271=500000 278=156430420 269=0 270=1.26177 271=5000000 278=156430414 269=0 270=1.26179 271=1000000 278=156430415 269=0 270=1.2618 271=600000 278=156430412 269=0 270=1.26178 271=3000000 278=156430413 10=002 

2018.12.11 04:36:17.651 GBPUSDi,M1: SendText : 8=FIX.4.4 9=144 35=V 49=icmarkets.3394382 56=cServer 57=QUOTE 50=TRADE2 34=2 52=20181211-12:36:17 262=1482094742 263=1 264=0 265=1 267=2 269=0 269=1 146=1 55=2 10=045 

 

from 35=W --  Bid : 1.2618 Ask : 1.26184 Spread : 0.4 

from 35=X which immediatly follows above 35=W -  Bid: 1.2618 Ask : 1.26189 Spread : 0.9 

 

35=W is received only once in the begining and after that all messages are 35=X.

Spread 0.9 pips from 35=X is Not consistent with the spread as in Icmarket cTrader.

 

 


@netread2004

netread2004
11 Dec 2018, 00:01


Hi Panagiotis,

I am trying to debug my program to find out why I am getting such higher values of spread when I use 35=X message to calculate Ask and Bid values.

Based on values I get from 35=X for Bid and Ask my spread  appears to be very high which is not consistent with cTrader spread for ICmarkets.

Not sure how else I can inteprete these messages to get correct value of spread.

The following message has both Ask and Bid values in single message that means both values updated in single message and are the latest one.

I calculate Max Bid and Min Ask to find out Spread as explained follows;

-------------------two consecutive FIX message for35=V and  35=X------------

2018.12.10 13:41:30.874 GBPUSDi,M1: ReceivedText : 8=FIX.4.4 9=388 35=X 34=16 49=cServer 50=QUOTE 52=20181210-21:41:33.571 56=icmarkets.3394382 57=TRADE2 268=7 279=0 269=1 278=104704685 55=2 270=1.25624 271=5000000 279=0 269=1 278=104704683 55=2 270=1.25622 271=3000000 279=0 269=0 278=104704680 55=2 270=1.25606 271=3000000 279=0 269=0 278=104704677 55=2 270=1.25605 271=5000000 279=2 278=104700659 55=2 279=2 278=104701794 55=2 279=2 278=104700078 55=2 10=058 

2018.12.10 13:41:30.873 GBPUSDi,M1: SendText : 8=FIX.4.4 9=142 35=V 49=icmarkets.3394382 56=cServer 57=QUOTE 50=TRADE2 34=16 52=20181210-21:41:23 262=6827819 263=1 264=0 265=1 267=2 269=0 269=1 146=1 55=2 10=200 
-----------------------------end of the messages-----------------

From above message New (279=0) values for Ask and Bid are as follows;

Ask Values - 1.25624, 1.25622   -- Minimum Ask - 1.25622

Bid Values : 1.25606, 1.25605  -- Maximum Bid - 1.25606

From above Spread = 1.6 pips

Not sure how I can get the correct spread value.  Is there any other way interpret these Ask and Bid value. I believe Spot value for Ask and Bid is Min Ask and Max Bid in a given single message. is that right?

Please comment on this and let me know if I can use some other alternative way to get these values right.

 

 


@netread2004

netread2004
10 Dec 2018, 15:20

For GBPUSD, with 35=W I get spread 1 to 6 points (I restart and send this message 3-5 time to get multiple spread values) which appear to be consistent with value I get in cTrader.

However, I receive 35=W only once when I send  MarketDataRequest message  and for next MarketDataRequest message i receive 35=X message.

If I only get 35=W only once then how can I get Ask and Bid on the fly constantly? Is there any way to get 35=W everytime I send MarketDataRequest?

 

 


@netread2004

netread2004
07 Dec 2018, 07:37

I just put these DataRequest in 500ms Timer Event and sending request every 500ms and now I am getting Quotes for 55=2. Is this the correct approach to get quotes? If so, 500ms is good time period or should it be faster. 

Please commnet on this.

 


@netread2004