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
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.
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.
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)
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.
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
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.
PanagiotisCharalampous
22 Jan 2024, 06:54
Hi there,
Please share with us the following
Best regards,
Panagiotis
@PanagiotisCharalampous