Subscription to account details
This page describes mechanism of receiving account data via websocket
Connection
In order to receive account data, the connection should be opened to wss://sandbox-api.traderevolution.com/traderevolution/v1/stream/accounts.
Please note that the URL specified for connection is default, but it can be customized according to the customer's requirements.
There is a "Ping-Pong" mechanism for WebSocket connections. To maintain active WebSocket connections and detect client inactivity, the following message format is used:
{"event": "PING", "t": 1731538318526}
{"event": "PONG", "t": 1731538318526}Subscribing to account data
The request body must contain the following parameters:
Body
event
string
Should be always subscribe in this case.
requestId*
integer
Request identifier generated by the client side. Will be used in the response.
payload
object
An object that contains information about the stream to which the subscription is made, see table below.
Payload object
accountId
Optional parameter that defines the ID of the account for which the subscription will be performed. If this parameter is not specified, then you will be subscribed to the updates of all accounts.
st*
The subscription type is specified here.
The following values can be used here:
accountDetailsData – this subscription provides information on account statistics: balances, account activity, margin, etc.
account – this subscription provides information regarding changes in the account settings, e.g., changes in the account status, changes in the risk rules, etc.
Request body example
Copy
Account details response structure
An object with the following parameters will be returned in the response for the subscription to the account details data:
d
Object with the account details data.
s
Subscription status indicator: ok or error in case the subscription fails.
errmsg
This parameter contains the text of the error which occurred when s=error.
st
Always returned as accountDetailsData here.
accountId
Identifier of the account.
The Account details array has the same sequence of parameters as in accountStateResponse model.
You can find the full list of parameters by following the link to stateResponse model:
Response example
Account response structure
An object with the following parameters will be returned in the response for the subscription to the account data:
d
Object with account settings.
s
Subscription status indicator: ok or error in case the subscription fails.
errmsg
This parameter contains the text of the error which occurred when s=error.
st
Always returned as account here.
accountId
Identifier of the account.
Unsubscribing from account data
To stop receiving updates for account data via WebSocket, you must send an unsubscribe request that mirrors the subscription format, with "event": "unsubscribe".
Request body parameters
event
string
Must always be "unsubscribe" in this case.
requestId*
integer
Client-side generated request identifier.
payload
object
Contains details for unsubscription. See table below.
Payload object
accountId
Optional. If provided, the unsubscription applies only to that account.
st
Required. The type of account subscription to unsubscribe from. Valid values: account, accountDetailsData.
Request body example:
Unsubscribing from all events
To unsubscribe from all account-related subscriptions for a specific account, omit the st parameter and provide only the accountId.
Example:
This will cancel all subscriptions (e.g., account, accountDetailsData) related to the specified account.
If accountId is also omitted, the unsubscription applies only to subscriptions without specific account targeting, as per user visibility.
Last updated