Connection Questions
Connection Questions
29 Mar 2017, 14:10
I have a few questions about making a connection:
- how often do I need to send Authorization?
- how can I detect when I need to send an authorization request again?
- can I log into an account simultaneously with the trading and accounts api? (i.e. 2 or more simultaneous connections)
Replies
ycomp
30 Mar 2017, 01:12
RE:
Spotware said:
Hi ycomp,
1) You need to get an authorization every time you establish the connection. Then you need to ping the server every ath least ten seconds to keep the connections alive.
2) If you have a trading api token you can access both scopes.
what is this heartbeat thing? I assume I can ignore using it if I ping the servers routinely?
@ycomp
Spotware
30 Mar 2017, 09:43
Hi ycomp,
1) what is this heartbeat thing? I assume I can ignore using it if I ping the servers routinely?
Heartbeat is used to keep the communication link alive while there is no activity from the client side. Preferably use heartbeat.
2) and what is a positionId ? like in ProtoOACreateOrderReq ?
The position ID is used when you want the order not to create a new position but merge the deals into an existing position. If for example you create a BUY position of €1000 EURUSD and then send another order request of €1000 EURUSD with direction BUY and pass the open position's ID, then the position will become €2000 BUY, instead of having two separate positions.
3) how can I convert an orderID into a positionID so that I can call ProtoOAClosePositionReq
When orders are executed, the positionID is returned. See ProtoOAExecutionEvent
@Spotware
ycomp
30 Mar 2017, 10:41
RE:
Spotware said:
Hi ycomp,
1) what is this heartbeat thing? I assume I can ignore using it if I ping the servers routinely?
Heartbeat is used to keep the communication link alive while there is no activity from the client side. Preferably use heartbeat.
just to confirm.. if I use heartbeat, then I don't need to ping at all ?
@ycomp
ycomp
30 Mar 2017, 10:45
how should I handle the situation where my program:
1. sends a market order request
2. connection drops
3. market order filled
4. response message missed (because not connected)
5. reconnected
so now on the server will be an open trade, that my program doesn't know was opened
@ycomp
Spotware
30 Mar 2017, 10:46
RE: RE:
ycomp said:
Spotware said:
Hi ycomp,
1) what is this heartbeat thing? I assume I can ignore using it if I ping the servers routinely?
Heartbeat is used to keep the communication link alive while there is no activity from the client side. Preferably use heartbeat.just to confirm.. if I use heartbeat, then I don't need to ping at all ?
Yes, for maithaining a live communication, sending heartbeats is adequate.
@Spotware
Spotware
30 Mar 2017, 11:42
RE:
ycomp said:
how should I handle the situation where my program:
1. sends a market order request
2. connection drops
3. market order filled
4. response message missed (because not connected)
5. reconnected
so now on the server will be an open trade, that my program doesn't know was opened
You can get an account's history at any time, including orders, positions and deals through Accounts API.
https://connect.spotware.com/docs/api-reference/accounts-api
@Spotware
mindbreaker
30 Mar 2017, 11:55
RE: RE:
Spotware said:
ycomp said:
how should I handle the situation where my program:
1. sends a market order request
2. connection drops
3. market order filled
4. response message missed (because not connected)
5. reconnected
so now on the server will be an open trade, that my program doesn't know was opened
You can get an account's history at any time, including orders, positions and deals through Accounts API.
https://connect.spotware.com/docs/api-reference/accounts-api
But in ConnectApi 2s refresh request interval exist (2 secomds in forex reality is eternity) !!!
@mindbreaker
Spotware
30 Mar 2017, 12:10
RE: RE: RE:
mindbreaker said:
Spotware said:
ycomp said:
how should I handle the situation where my program:
1. sends a market order request
2. connection drops
3. market order filled
4. response message missed (because not connected)
5. reconnected
so now on the server will be an open trade, that my program doesn't know was opened
You can get an account's history at any time, including orders, positions and deals through Accounts API.
https://connect.spotware.com/docs/api-reference/accounts-apiBut in ConnectApi 2s refresh request interval exist (2 secomds in forex reality is eternity) !!!
Yes this is true for subsequent requests, but what ycomp desrcibes is a rare scenario which will not happen every less than two seconds.
@Spotware
ycomp
30 Mar 2017, 14:04
I'm a bit confused as to how to implement heartbeat. I'm gettting heartbeat events, what do I do when I receieve them?
Do I ever need to actually create a heartbeat event ? I don't really understand why I would need to create one if the server already sends them periodically.
But I don't know how to acknowledge to the server that I recieved the heartbeat event.
@ycomp
Spotware
30 Mar 2017, 15:31
1) in the docs it says "volume" is required, what value should I specify for volume to signify that the entire position should be closed? 0 doesn't work.
Yes, indeed. The volume is required. Apologies for the previous answer.
2) Heartbeat.
You do not need to aknowledge heartbeat receipt to the server. The server just lets you know that it is alive, in case your application needs this info. In a similar way, You will need to send a heartbeat to the server that your application is alive so the server keeps the connection open.
@Spotware
Spotware
31 Mar 2017, 10:02
Hi ycomp,
Currently you cannot determine bedorehand if a symbol is tradable or not. When orders are send for a symbol in non tradable hours, you will receive a rejection message with error code MARKET_CLOSED. Please see https://connect.spotware.com/docs/api-reference/developer-library/common-model-messages
@Spotware
Spotware
29 Mar 2017, 14:23
Hi ycomp,
1) You need to get an authorization every time you establish the connection. Then you need to ping the server every ath least ten seconds to keep the connections alive.
2) If you have a trading api token you can access both scopes.
@Spotware