Closed achille1112 closed 3 years ago
It just means the buffer was empty. Here if call “get” on empty buffer then an exception is thrown. Can just do “if buf.size()>0; e=buf.get(); end
Ok, thank you very much for your answer. The buffer is empty when there are not open positions at the start of the session?
Best regards. Domenico
If there are no open positions the request doesn't return anything so the buffer remains empty. But even if there are positions it can sometimes take 1-2s for them to show up in the buffer so it can be a good idea to implement a loop that waits for something to drop in the buffer. This is true also for other requests. Especially if you have a fast computer you often have to wait for the answer of the API.
Thanks Despair2000! But even if I wait some minutes I obtain the same error.
Best regards. Domenico
And you have open positions?
Minutes it should definitely not take.
When there are not open positions at the start of the session I obtain the error indipendently from the seconds that I wait. If I open position and after I close position (there are no open positions) then I not obtain the error.
Best regards Domenico
Ok, and what happens if there is an open position?
If there is an open position at the start of the session I obtain no error.
Best regards Domenico
Sounds like all works fine. A closed position is often still returned but with positionSize 0.
Ok thanks Despair2000! Then if I open a position and after I close the position I obtain no error because the position is with positionSize=0. If there is no open position at the start of the session I obtain the error because there is no position in the buffer.
Is that right or did I get it wrong?
Best regards Domenico
When you create the buffer it is obviously empty. When you request the open positions while there is a position the request returns this position to the buffer. When you close the position the same position is still returned on request with size 0.
You should see that if you look at the returned data.
Thank you very much Despair!
Best Regards Domenico
Dear Abel, I have a problem when I request my positions via API using the following code:
I obtain the following error:
Even if I wait several seconds I always get the same error.
Could you help me to understand why this happens?
Best Regards. Domenico.