Request for Positions - not returning data for all open positions

Created at 21 Jan 2024, 17:51
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!
WI

wiktor.kisielewski

Joined 10.09.2019

Request for Positions - not returning data for all open positions
21 Jan 2024, 17:51


Hello,
 

According to the docs: https://help.ctrader.com/fix/specification/#request-for-positions-msgtype35an
If during sending the message “35=AN” the tag “721” → “A position ID to request. If not set, all open positions will be returned.”
Yet I get the response with only one (random?) symbol, while having a few open positions. Why is that?


Example request:
```
8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240121-17:40:33.789|56=CSERVER|57=TRADE|50=any_string|710=2|10=187
```
Response:
```
8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240121-17:40:33.806|56=XXX|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=245
```

Also if I resend the same AN few times it returns positions for other symbols


@wiktor.kisielewski
Replies

PanagiotisCharalampous
22 Jan 2024, 06:54

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis


@PanagiotisCharalampous

wiktor.kisielewski
22 Jan 2024, 07:13

RE: Request for Positions - not returning data for all open positions

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               
│ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

@wiktor.kisielewski

wiktor.kisielewski
22 Jan 2024, 07:13

RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

@wiktor.kisielewski

PanagiotisCharalampous
22 Jan 2024, 09:41

RE: RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

Thank you, can you also advise the host you are using for your FIX API connection?


@PanagiotisCharalampous

wiktor.kisielewski
22 Jan 2024, 12:25

RE: RE: RE: RE: Request for Positions - not returning data for all open positions

PanagiotisCharalampous said: 

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

Thank you, can you also advise the host you are using for your FIX API connection?

sure, it is “h51.p.ctrader.com”


@wiktor.kisielewski

wiktor.kisielewski
22 Jan 2024, 12:43

RE: RE: RE: RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

Thank you, can you also advise the host you are using for your FIX API connection?

sure, it is “h51.p.ctrader.com”

I've now also switched to a different (syggested in web ctrader) → “demo1.p.ctrader.com” . There is no difference


@wiktor.kisielewski

wiktor.kisielewski
24 Jan 2024, 07:49 ( Updated at: 24 Jan 2024, 12:41 )

RE: RE: RE: RE: RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

Thank you, can you also advise the host you are using for your FIX API connection?

sure, it is “h51.p.ctrader.com”

I've now also switched to a different (syggested in web ctrader) → “demo1.p.ctrader.com” . There is no difference

@PanagiotisCharalampous Should I expect some update here?


@wiktor.kisielewski

ctid1980098
29 Jan 2024, 08:01

Hi,

I don't see any code for how you may be reading from the server but are you sure you are reading all the responses from the server? Like reading in a loop or something? It could be that maybe you are just reading only the first message only? On my end I am able to receive all open positions back from server. tested on my app for up to 8 positions. 


@ctid1980098

PanagiotisCharalampous
29 Jan 2024, 08:23

RE: RE: RE: RE: RE: RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

wiktor.kisielewski said: 

wiktor.kisielewski said: 

PanagiotisCharalampous said: 

Hi there,

Please share with us the following

  1. Complete requests and responses sent and received, accompanied with timestamps 
  2. Screenshots from cTrader demonstrating that there are more positions open than the ones returned.

Best regards,

Panagiotis

│ POSITION REQUEST: 8=FIX.4.4|9=102|35=AN|34=2|49=demo.icmarkets.8857612|52=20240122-07:11:05.424|56=CSERVER|57=TRADE|50=any_string|710=2|10=170                                                               │ REQUEST RESPONSE: 8=FIX.4.4|9=155|35=AP|34=2|49=CSERVER|50=TRADE|52=20240122-07:11:05.441|56=demo.icmarkets.8857612|55=1006|710=2|721=403537453|727=18|728=0|730=1.4606|702=1|704=0|705=1000|10=237

Thank you, can you also advise the host you are using for your FIX API connection?

sure, it is “h51.p.ctrader.com”

I've now also switched to a different (syggested in web ctrader) → “demo1.p.ctrader.com” . There is no difference

@PanagiotisCharalampous Should I expect some update here?

Hi there,

We inspected our logs and all positions are returned. So it could be some issue in your code. If you can reproduce the issue using the FIX API Example, so that we can reproduce it as well, we would be happy to have a look at this again.

Best regards,

Panagiotis


@PanagiotisCharalampous

wiktor.kisielewski
29 Jan 2024, 08:25

RE: Request for Positions - not returning data for all open positions

ctid1980098 said: 

Hi,

I don't see any code for how you may be reading from the server but are you sure you are reading all the responses from the server? Like reading in a loop or something? It could be that maybe you are just reading only the first message only? On my end I am able to receive all open positions back from server. tested on my app for up to 8 positions. 

Hm, Im using socket connection (python - combined with simplefix library)

The code for sending and receiving is:

```
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

s.connect((auth.SocketConnectHost, auth.T_SocketConnectPort))

parser = FixParser()

def request_for_positions():

message = FixMessage()

message.append_pair(8, "FIX.4.4")

message.append_pair(35, "AN")

message.append_pair(34, n)

message.append_pair(49, auth.SenderCompID)

message.append_utc_timestamp(52)

message.append_pair(56, auth.TargetCompID)

message.append_pair(57, "TRADE")

message.append_pair(50, "any_string")

message.append_pair(710, str(n))

 

message.remove(721)


 

parser.append_buffer(message.encode())

sent = parser.get_message()

s.send(message.encode())


 

response = s.recv(2048)

parser.append_buffer(response)

out = parser.get_message()

```


@wiktor.kisielewski

ctid1980098
29 Jan 2024, 08:43

RE: RE: Request for Positions - not returning data for all open positions

response = s.recv(2048)

the line above is is probably an indication that you are not receiving messages in a loop or asynchronously and hence why you are not receiving the multiple messages being sent from server. You would need to rethink how you are writing your code and would also need to read field 9= to determine how much bytes you will need to receive or something along those lines. I have not used simplefix so don't know much about it but I have written application from scratch. 

You will need to rewrite your code so that you can read multiple messages from server in order to see other opened positions. My suggestion is to write from scratch as i found it easier to understand. 


@ctid1980098

wiktor.kisielewski
29 Jan 2024, 08:45

RE: RE: RE: Request for Positions - not returning data for all open positions

ctid1980098 said: 

response = s.recv(2048)

the line above is is probably an indication that you are not receiving messages in a loop or asynchronously and hence why you are not receiving the multiple messages being sent from server. You would need to rethink how you are writing your code and would also need to read field 9= to determine how much bytes you will need to receive or something along those lines. I have not used simplefix so don't know much about it but I have written application from scratch. 

You will need to rewrite your code so that you can read multiple messages from server in order to see other opened positions. My suggestion is to write from scratch as i found it easier to understand. 

could you share some code snippets of your code? That would be very usefull 


@wiktor.kisielewski

ctid1980098
29 Jan 2024, 09:02

RE: RE: RE: RE: Request for Positions - not returning data for all open positions

wiktor.kisielewski said: 

ctid1980098 said: 

response = s.recv(2048)

the line above is is probably an indication that you are not receiving messages in a loop or asynchronously and hence why you are not receiving the multiple messages being sent from server. You would need to rethink how you are writing your code and would also need to read field 9= to determine how much bytes you will need to receive or something along those lines. I have not used simplefix so don't know much about it but I have written application from scratch. 

You will need to rewrite your code so that you can read multiple messages from server in order to see other opened positions. My suggestion is to write from scratch as i found it easier to understand. 

could you share some code snippets of your code? That would be very usefull 

there are many examples online for various languages on how to read continuously from sockets. They are incredibly useful to help get you started. In fact reading previous questions asked on this forum give good code snippets that will help to get you started. 


@ctid1980098