Trading accounts

This section describes adding a trading account to the created user. Please note that trading is unavailable without at least one account assigned to the user by his ID. The article shows the process of adding a trading account. Please note that you can use account presets here, find more info on managing these presets in the corresponding articlearrow-up-right.

circle-check

The account is created with a server currency (Configuration > Settings > General) and is in an Active state by default (ready for trade after the deposit). The account ID will be used in your following requests, i.e. to perform deposit or other account operations.

Add trading account

POST /accounts

This method is used for the creation of a trading account and assigning it to a certain user by its ID.

Body

Name
Type
Description

accountName

string

Name of the new account

userId

integer

ID of the user, to which this trading account will be assigned

Request

{
  "accountName": "1234acc",
  "userId": 146695
}

CURL

curl -X POST "http://sandbox.traderevolution.com:8443/proftrading/rest/accounts" -H "accept: application/json" -H "Authorization: Bearer eyItMjI2OTkxMTE4IjotMjI2OTkxMTE...3QypO3xI7LJkLEiuMnd4_epgBqF3z_TRGULkAIAAA.4P7Xssd4FUvIWg2F3Evfd7YGInHwQ-rGfBsBOWbJpPo" -H "Content-Type: application/json" -d "{ \"accountName\": \"1234acc\", \"userId\": 146695}"

Response

Please note that you can create a trading account and assign it to the user using two parameters only: accountName and userId. In this case, standard settings will be applied to the newly created account:

  • currency = server currency (configuration > settings > general)

  • type: 0 = single account

  • status: 0 = active

  • mode: 1 = Live

Find trading accounts by user ID

GET/users/{userId}/accounts

This method allows to find all trading accounts of the user by his ID.

Path

Name
Type
Description

userId

integer

ID of the user whose trading accounts will be returned in the response

CURL

Response

In response, you will get the ID of all accounts linked to the specified user.

Changing account status

PATCH/accounts/{account ID}

This section describes the process of changing the account status (i.e. only one parameter will be updated) with a PATCH method. Please note that you can change any account setting using this method.

circle-check

CURL

As you can see, the request contains the account ID and a new status value "1"- which means the account will be closed. Available values here are 0 - Active, 1 - Closed, 2 - Suspended, 3 - Trading is disabled by risk rules, and 5 - Liquidation only (the account can only close positions and cancel orders).

Response

You will receive the 204 (No content) code in the response, meaning the account has been patched successfully.

Current account status

GET/accounts/{accountId}

This method returns all settings of the account by its ID. This section describes the status field.

Path

Name
Type
Description

accountId

integer

ID of the account whose settings will be returned

CURL

Response example

You should find the status field, it contains the current status of the account. Available values here are 0 - ACTIVE, 1 - CLOSED, 2 - SUSPENDED, 3 - TRADE_OFF (trading is disabled), and 5 - LIQUIDATION_ONLY (account can only close positions and cancel orders). As you can see from the example, we have an active account "accountName": "account1 with "status": 0.

Delete trading account by ID

DELETE/accounts/{accountId}

This method is used for removing a trading account from the server (it will be unassigned from the user-owner as well).

triangle-exclamation

Path

Name
Type
Description

accountId

integer

ID of the account to be removed from the server

CURL

You will receive the 204 (No content) code in the response, meaning the account has been deleted successfully.

Get account details

GET/accountDetails

This request allows receiving the details for the required account. You can filter results by Account ID, request info by User group ID (for all users from the required group), or by User ID (data for all his accounts). The appropriate filtration should be specified in the request query.

Query

Name
Type
Description

accountId

string

Identifier of the account for which the data is retrieved.

userGroupId

string

Identifier of the user group for which the data is retrieved.

userId

string

Identifier of the user for which the data is retrieved.

CURL (example for account 146696)

Response

As you can see, the response contains the account/user ID and an object with all his indicators at the moment. The name of each parameter speaks for itself, but you can find a full description of each of them by following this linkarrow-up-right.

Last updated