> For the complete documentation index, see [llms.txt](https://guide.traderevolution.com/traderevolution-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.traderevolution.com/traderevolution-api/traderevolution-apis/client-api/account-management.md).

# Account management

Each user created in the system has at least one trading account assigned to it. This section describes some of the available methods for user account management.

{% hint style="success" %}
A full list of available methods and their parameters can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account>
{% endhint %}

### Get accounts list

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts`

This method is used to get the list of trading accounts available for the user with some of their settings. Please note that the user is identified by the token sent in the request so the info will be returned for this user only.&#x20;

The response will contain an array of objects. Each object contains information on one account, there will be as many objects as the user has accounts. There is an “id” parameter that contains an account identifier, the value of this parameter should be used in your subsequent API calls. No additional parameters are used in this request.&#x20;

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAt...ANvtqQ92fTM_1EIGdm2fr4ZrL5omdKvojmrf2eR9fWSz6eZwllr-P1QvhwlG62LECoFL1kCm2gH5x_EcHV5Ff6ZwX5NDXgXL1t8MQUemeysdwIkxcM5i4YERR8s16UQ"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}
{% code overflow="wrap" %}

```json
{
  "s": "ok",
  "d": {
    "accounts": [
      {
        "id": "3243753",
        "name": "test",
        "type": "demo",
        "currency": "USD",
        "status": "ACTIVE",
        "tradingRules": {
          "supportBrackets": true,
          "supportTrailingStop": true,
          "supportPartialClosePosition": true,
          "supportSelfTrading": true,
          "supportTradingOutOfTradingHours": false
        },
        "riskRules": {
          "totalMaxPositionQty": 500,
          "maxTrailingDrawdown": 800,
          "maxPositionsNumber": 3,
          "maxPendingOrdersNumber": 60,
          "maxOrderCapital": 1500,
          "maxOrderAmount": 150,
          "dailyProfitTarget": 500,
          "maxDrawdownLevel": 1000,
          "maxOrdersCount": 500,
          "positionLossLimit": 96,
          "balanceRelativeDrawdown": 100,
          "dailyLossLimit": {
            "value": 200,
            "warnLevel1": null,
            "warnLevel2": null
          },
          "weeklyLossLimit": {
            "value": 490,
            "warnLevel1": null,
            "warnLevel2": null
          },
          "unrealizedLossLimit": {
            "value": 600,
            "warnLevel1": null,
            "warnLevel2": null
          }
        },
        "marginRules": {
          "stopOutLevel": 100,
          "marginWarningLevel": 90,
          "smaEquity": null,
          "waivedMargin": -1
        },
        "additionalInfo": []
      }
    ]
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

As a result, you will get a data object which contains an array of all user accounts with their settings (currency, risk rules, etc.). This example contains one account, with "3243563" id, "USD" currency, and "test" name. Standard errors can be received here as well. Those settings that are not configured for the account, are shown as <mark style="color:red;">`null`</mark>.&#x20;

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getAccounts>
{% endhint %}

### Account information (instruments, orders, positions, etc.)

This part of the API is intended to get more detailed information about the account, such as orders, positions, instruments available for the account, etc. Each request requires the `accountId` parameter to get information for a specific account.

### Available instruments&#x20;

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/instruments`

This method returns a list of instruments available for trading with the specified account (`accountId`), i.e. a list of instruments that are visible to him. The following parameters should be added to the query.path of the request:

**Query/path**

| Name         | Type         | Description                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ------------ | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId*` | integer/path | Account identifier.                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `locale`     | string/query | <p>Locale (language) id.</p><p>Available values: <code>ar</code>, <code>en</code>, <code>es</code>, <code>fr</code>, <code>ja</code>, <code>ko</code>, <code>pl</code>, <code>pt</code>, <code>ru</code>, <code>tr</code>, <code>ua</code>, <code>zh\_sm</code>, <code>zh\_tr</code></p>                                                                                                                                                              |
| `type`       | string/query | <p>Symbol type. Possible values: <code>crypto</code><em>,</em> <code>equity</code><em>,</em> <code>equity\_cfd</code><em>,</em> <code>etf</code><em>,</em> <code>forex</code><em>,</em> <code>futures</code><em>,</em> <code>futures\_cfd</code><em>,</em> <code>indices</code><em>,</em> <code>options</code><em>,</em> <code>spreadbet</code> , <code>fund</code>.</p><p>Note that several types can be specified using a comma as a separator.</p> |

**CURL (example for&#x20;*****Crypto*****&#x20;type)**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/instruments?type=crypto" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW…UP4-vRYErHTG3MFReIza7Y0pGYOC647P_ZgJQxMstmu9AX_fCb-4gZWfUpcvjmY8YQLFP7ZJ1VtAw"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "instruments": [
      {
        "tradableInstrumentId": 11681,
        "id": 13671,
        "name": "ETHUSD",
        "description": "Ether coin - United States dollar",
        "type": "CRYPTO",
        "tradingExchange": "Crypto",
        "marketDataExchange": "Crypto",
        "country": "US",
        "logoUrl": null,
        "localizedName": "ETHUSD",
        "barSource": "BID",
        "hasIntraday": true,
        "hasDaily": true,
        "tickSize": [
          {
            "leftRangeLimit": 0,
            "tickSize": 0.01
          }
        ],
        "tickCost": 0.05
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object that contains the instruments array, where each object contains full information about each instrument available to this particular account. As you can see from the example, only one crypto instrument is available for account:3243563.&#x20;

Standard errors can be received as well. If the setting is not configured at the instrument level, the <mark style="color:red;">`null`</mark> value will be returned for it.&#x20;

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getInstruments>
{% endhint %}

## Account related executions

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/executions`

This method returns all executions (order fills, trades, etc.) related to the account specified using the `{accountId}`. Please note that the response only contains trades that were performed in the last 24 hours.

**Path/Query**

| Name            | Type          | Description                                                                                                                                                                                                                                                    |
| --------------- | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId*`    | integer/path  | Identifier of the account for which executions are returned.                                                                                                                                                                                                   |
| `from`          | integer/query | A Unix timestamp in milliseconds (UTC) representing the start of the time range. Ignored if `numberOfLines` is set.                                                                                                                                            |
| `to`            | integer/query | A Unix timestamp in milliseconds (UTC) representing the end of the time range. Ignored if `numberOfLines` is set.                                                                                                                                              |
| `positionId`    | integer/query | Filters executions for a specific position. Ignored if `numberOfLines` is set.                                                                                                                                                                                 |
| `numberOfLines` | integer/query | <p>Number of records to return. If provided, acts as a pagination limit and overrides time range filters. </p><p>Not compatible with <code>positionId</code> or <code>from/to</code> and can be used together with <code>eventId</code>.</p>                   |
| `eventId`       | integer/query | The unique identifier of the event (position update) from which the next set of data will be retrieved. Serves as a cursor for pagination to return subsequent records starting after the specified execution event. Used in combination with `numberOfLines`. |

{% hint style="danger" %}
When using `numberOfLines`, the method switches to pagination mode. If the request contains only `numberOfLines`, the API will return the last N events.&#x20;

On subsequent requests, both `eventId` and `numberOfLines` should be provided to retrieve the next set of records.
{% endhint %}

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243668/executions" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iL…eBKDkgf4QYbrXTPhZG4OmIZKPxutumkbWqWZ8jf-tbAJmI20nxhO0Qajnuri3agtY4um20wtLGjKsMiMBpA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "executions": [
      [
        "69737",
        "1.08068",
        "sell",
        "1718272419632",
        "100000.00",
        "3185822",
        "3171801",
        "922",
        "EUR/USD",
        "FOREX",
        "OANDA",
        "0",
        "Opened",
        "100000",
        "1",
        "0",
        "Long"
      ],
      [
        "69738",
        "1.08125",
        "buy",
        "1718272512456",
        "50000.00",
        "3185823",
        "3171802",
        "923",
        "GBP/USD",
        "FOREX",
        "ICMarkets",
        "0",
        "Open",
        "50000",
        "1",
        "0",
        "Long"
      ]
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object that contains the executions array, where each object contains full information about trade (Trade ID, Price, Side, Created Date (Unix timestamp), Quantity, Order ID, Position ID, Tradable Instrument ID, Instrument Name, Instrument Type, Trading Exchange, PnL, Position Status, Position Amount, Position Change, Event Trigger, Position side).&#x20;

Possible **Position statuses**: *Opened, Closed* and *Open* (for modified positions)*.* Possible **Event trigger** values: 1 - risk rule; 2 - stop loss order; 3 - take profit order; 4 - stop limit loss order; 5 - corporate action; 6 - back office manual correction; 7 - recurring investment / auto-invest; 0 - all other events.

The sequence of returned parameters is described in the [*Config* ](/traderevolution-api/traderevolution-apis/client-api/config-basic-settings-and-accesses.md)article in more detail. All info is related to the account specified in a request.

Standard errors can be received as well.

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getExecutions>
{% endhint %}

## Active orders of the account

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/orders`

This method returns all active orders related to the specified account. Please note that the response contains all orders that are active during the current session and active orders from previous sessions as well.

**Query/Path**

| Name                   | Type          | Description                                                                                                                                                                                                                                                      |
| ---------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId*`           | integer/path  | Identifier of the account for which active orders are returned.                                                                                                                                                                                                  |
| `from`                 | integer/query | Unix timestamp in milliseconds (UTC) of the leftmost date (entered date is included as well). Together with `to` they form a range. The orders that were created in the specified range will be returned. If not specified, then all active orders are returned. |
| `to`                   | integer/query | Unix timestamp in milliseconds (UTC) of the rightmost date (entered date is included as well). Together with `from` they form a range. The orders that were created in the specified range will be returned. If not specified all active orders are returned.    |
| `tradableInstrumentId` | integer/query | You can specify the instrument ID here, in case you need active orders placed for the specific instrument only.                                                                                                                                                  |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/orders" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnlu…gJ4sNtNrnWjYZc3jVD7dZiIzTbmoy6DmbXJUqjd3PYbJ-ouapaL1JwhzGRsRx7ockUcG-MXGxgHNezd9nvYA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "orders": [
      [
        "3185797",
        "922",
        "1.0",
        "buy",
        "stop",
        "New",
        null,
        null,
        null,
        "1.2",
        "DAY",
        null,
        "1717676474545",
        "1717676474000",
        "true",
        null,
        null,
        null,
        null,
        null,
        "EUR/USD",
        "FOREX",
        "FX"
      ]
    ]
  }
}

```

{% endtab %}
{% endtabs %}

As a result, you will get a data object that contains the orders array, where each object contains full information about an order (columns: ID, Instrument ID, Qty, Side, Type, Status, Filled qty, avgPrice, Price, stopPrice, Validity, expireDate, createdDate, lastModified, isOpen, positionId, Stop loss, Stop loss type,Take profit, Take profit type, Instrument name, Instrument type, Exchange). All info is related to the account specified in a request. All `time` parameters are presented as the Unix timestamp. The sequence of returned parameters is described in the [*Config* ](/traderevolution-api/traderevolution-apis/client-api/config-basic-settings-and-accesses.md)article in more detail.

Standard errors can be received as well. If some parameter is not applicable for this order (for example this order does not have *filled qty* yet) then it will be returned as <mark style="color:red;">`null`</mark>.

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getOrders>
{% endhint %}

## Account custom report

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/customReport/{reportId}`

This method returns data from a custom report created on the server for the specified trading account. The report can optionally be filtered by a date range using the **from** and **to** query parameters. Both parameters must be specified together. If they are omitted, all available report data is returned.

**Query/Path**

<table data-search="false"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code>reportId*</code></td><td>integer/path</td><td>Identifier of the report that being requested.</td></tr><tr><td><code>accountId*</code></td><td>integer/path</td><td>Identifier of the trading account to obtain data for.</td></tr><tr><td><code>from</code></td><td>integer/query</td><td>Unix timestamp in milliseconds (UTC) of the leftmost date (entered date is included as well). Together with <code>to</code> they form a range. If not specified, then all orders are returned.</td></tr><tr><td><code>to</code></td><td>integer/query</td><td>Unix timestamp in milliseconds (UTC) of the rightmost date (entered date is included as well). Together with <code>from</code> they form a range. If not specified all orders are returned.</td></tr></tbody></table>

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/customReport/151?from=1607251624000&to=1609853624000" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRm…l12XAYciC_-d_nbsRIzEM4eZyOSqUUt0qdcXAzz0W6k7v4dANQRuPZGUPH6_UAaAc3dCONqn5uImi8euwwA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "headers": [
      "date",
      "eodBalance",
      "unrealizedPL",
      "currency"
    ],
    "data": [
      [
        1607251624000,
        100000.00,
        1500.50,
        "USD"
      ],
      [
        1607251624111,
        101500.50,
        2300.75,
        "USD"
      ]
    ]
  }
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object containing the **headers** array and the **data** array. The **headers** array defines the names and order of the report columns, while each row in **data** contains values in the corresponding order. Since custom reports may have different structures, the list of columns is returned together with the report data.

{% hint style="warning" %}
All time values are represented as Unix timestamps in milliseconds. If no data matches the specified filters, an empty **data** array will be returned. Standard errors can be received as well, for example if the report is unavailable, the user does not have access to it, or the request exceeds the rate limit.
{% endhint %}

## Order history by account

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/ordersHistory`

This method returns order history related to the specified account. Please note that the response contains all orders that have the final status (*filled, rejected, canceled, etc.*).

{% hint style="warning" %}
Only one of the following filters can be set at a time: `orderId`, `positionId`, or `tradeId`.
{% endhint %}

**Query/Path**

| Name                   | Type          | Description                                                                                                                                                                         |
| ---------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId*`           | integer/path  | Identifier of the account for which the orders history is returned.                                                                                                                 |
| `from`                 | integer/query | Unix timestamp in milliseconds (UTC) of the leftmost date (entered date is included as well). Together with `to` they form a range. If not specified, then all orders are returned. |
| `to`                   | integer/query | Unix timestamp in milliseconds (UTC) of the rightmost date (entered date is included as well). Together with `from` they form a range. If not specified all orders are returned.    |
| `tradableInstrumentId` | integer/query | You can specify the instrument ID here, in case you need orders for the specific instrument only.                                                                                   |
| `orderId`              | integer/query | Filter by a specific Order ID. Only one ID filter is allowed per request.                                                                                                           |
| `positionId`           | integer/query | Filter by a specific Position ID. Only one ID filter is allowed per request.                                                                                                        |
| `tradeId`              | integer/query | Filter by a specific Trade ID. Only one ID filter is allowed per request.                                                                                                           |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/ordersHistory" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRm…l12XAYciC_-d_nbsRIzEM4eZyOSqUUt0qdcXAzz0W6k7v4dANQRuPZGUPH6_UAaAc3dCONqn5uImi8euwwA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
    "d": {
        "ordersHistory": [
            [
                "256041",
                "334974",
                "1.00",
                "buy",
                "market",
                "Filled",
                "1",
                "78.97",
                "78.97",
                "0",
                "DAY",
                null,
                "1717683561023",
                "1717683561000",
                "true",
                "148487",
                null,
                null,
                null,
                null,
                "EUR/USD",
                "FOREX",
                "FX"
            ],
            [
                "255990",
                "334974",
                "3.00",
                "buy",
                "market",
                "Filled",
                "3",
                "80",
                "80",
                "0",
                "IOC",
                null,
                "1717662254485",
                "1717662255000",
                "true",
                "148477",
                null,
                null,
                null,
                null,
                "EUR/CHF",
                "FOREX",
                "FX"
            ]
        ]
    },
    "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object that contains the orders array, where each object contains full information about an order (columns: ID, Instrument ID, Qty, Side, Type, Status, Filled qty, avgPrice, Price, stopPrice, Validity, expireDate, createdDate, lastModified, isOpen, positionId, Stop loss, Stop loss type, Take profit, Take profit type, Instrument name, Instrument type, Exchange). All info is related to the account specified in a request. All `time` parameters are presented as the Unix timestamp. The sequence of returned parameters is described in the [*Config* ](/traderevolution-api/traderevolution-apis/client-api/config-basic-settings-and-accesses.md)article in more detail.

Standard errors can be received as well. If some value is absent (for example, the Stop loss is not configured), the <mark style="color:red;">`null`</mark> value will be returned.&#x20;

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getOrdersHistory>
{% endhint %}

## Positions of the account

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/positions`

This method returns all positions of the specified account. Please note that the response contains all positions which are currently open.

**Query/Path**

| Name                   | Type          | Description                                                                                                             |
| ---------------------- | ------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `accountId*`           | integer/path  | Identifier of the account for which the positions are returned.                                                         |
| `tradableInstrumentId` | integer/query | You can specify the instrument ID here, in case you need to find out opened positions for the specific instrument only. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/positions" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0i…JsHYjPIj5PAuFXlzyiFJmw3IPkVU9vZozv5l_KVkEUpTDhfgARcghbgStPXkB1Ij81CN5b0twVV-re1bXQ"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "positions": [
      [
        "3171790",
        "922",
        "buy",
        "1",
        "1.08647",
        null,
        null,
        "1717676448738",
        "268.00",
        "EUR/USD",
        "FOREX",
        "FX",
        null,
        null
      ],
      [
        "3171791",
        "922",
        "buy",
        "1",
        "1.0885",
        null,
        null,
        "1717683337691",
        "65.00",
        "EUR/USD",
        "FOREX",
        "FX",
        null,
        null
      ]
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will get a data object that contains the positions array, where each object contains full information about each position (columns: ID, Instrument ID, Side, Qty, avgPrice, Stop loss ID, Take profit ID, Open date, Unrealized P/L, Instrument name, Instrument type, Exchange, Stop loss, Take profit). All info is related to the account specified in a request. All `time` parameters are presented as the Unix timestamp. The sequence of returned parameters is described in the [*Config* ](/traderevolution-api/traderevolution-apis/client-api/config-basic-settings-and-accesses.md)article in more detail.

Standard errors can be received as well. If some value is absent (for example, the Stop loss is not configured), the <mark style="color:red;">`null`</mark> value will be returned.&#x20;

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getPositions>
{% endhint %}

## Risk rules of account

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/riskRulesCounters`

This method returns the state of risk rule counters for the specified account. Please note that the response contains only current values of risk rules.

**Path**

| Name         | Type    | Description                                                  |
| ------------ | ------- | ------------------------------------------------------------ |
| `accountId*` | integer | Identifier of the account for which risk rules are returned. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243753/riskRulesCounters" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iLC…JsHYjPIj5PAuFXlzyiFJmw3IPkVU9vZozv5l_KVkEUpTDhfgARcghbgStPXkB1Ij81CN5b0twVV-re1bXQ"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "currentDailyLoss": 50,
    "relativeDailyLoss": null,
    "currentWeeklyLoss": 500,
    "relativeWeeklyLoss": null,
    "currentUnrealizedLoss": null,
    "relativeUnrealizedLoss": null,
    "currentDailyProfit": 80,
    "relativeDailyProfit": null,
    "relativeTrailingDrawdown": null,
    "relativeMaxDrawdown": 300,
    "relativeMaxRelativeDrawdown": null,
    "currentTotalPositionQty": 100,
    "currentPositionsNumber": 50,
    "currentPendingOrdersNumber": null,
    "currentOrdersCountPerDay": null
  }
}
```

{% endtab %}
{% endtabs %}

As a result, you will get all risk rules and their values in the response. All info is related to the account specified in a request.&#x20;

Standard errors can be received as well. If some value is absent (risk rule is not configured), the <mark style="color:red;">`null`</mark> value will be returned.&#x20;

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getRiskRulesCounters>
{% endhint %}

## Account state

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/state`

This method returns the current state of the specified account. Please note that the response contains various parameters that describe the current account state. All these account details can be determined using the <mark style="color:blue;">`GET`</mark>`/traderevolution/v1/config` method, section: *accountDetailsConfig* (see General description of Client REST API).

**Path**

| Name         | Type    | Description                                                       |
| ------------ | ------- | ----------------------------------------------------------------- |
| `accountId*` | integer | Identifier of the account for which account details are returned. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/state" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0i…mP55r6pWUT2u_pGj6Cq3-cmMV-KZqvlwX2XksZxvK3542iJpr4TUPv6shbR9ltODjdyxwcORfsMeDkFUzjVIA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "accountDetailsData": [
      100078,
      100531,
      93103.6,
      0,
      100078,
      0,
      93103.6,
      0,
      0,
      6974.4,
      5666.7,
      90,
      0,
      0,
      100,
      5666.7,
      94411.3,
      0,
      0,
      0,
      0,
      0,
      453,
      453,
      2,
      0,
      5.66228342,
      6.96896421,
      5.66228342,
      5666.7,
      1500.0,
      0,
      0,
      0        
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will get details for the specified account (the order of the columns is the same as in the response: Balance, Projected balance, Available funds, Blocked balance, Cash balance, Unsettled cash, Withdrawal available, Stocks value, Option value, Initial margin req, Maintenance margin req, Margin warning level, Blocked for stocks, Stock orders req, Stop out level, Warning margin req, Margin before warning, Today gross, Today net, Today fees, Today volume, Today trades count, Open gross P/L, Open net P/L, Positions count, Orders count, Maintenance margin req %, Initial margin req %,  Warning margin req %, Stop out value, Credit, Fixed income orders req, Blocked for fixed income, Fixed income value).&#x20;

Standard errors can be received as well. If some value is absent, a <mark style="color:red;">`0`</mark> value will be returned.&#x20;

{% hint style="success" %}
A detailed description of the method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getState>
{% endhint %}

## Account statement

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/accounts/{accountId}/statements`

This method retrieves the logs of all account operations performed by the account for either the current day, a specific time range, or based on a specified number of records. The response includes an array of headers that define the structure of the data, followed by an array of rows containing operation details.\
You can retrieve operations either by specifying a time range (`from`, optionally `to`) or by requesting a specific number of records (`numberOfLines`, optionally with `operationId`) to paginate through the data.

{% hint style="warning" %}
Note the following:

* If the `numberOfLines` parameter is provided in the request, the `from` and `to` parameters are ignored;
* When `from` and `to` parameters are specified (without `numberOfLines`), only operations that fall within this time range will be returned. Provided `operationId` will be ignored.
  {% endhint %}

**Path/Query**

| Name            | Type          | Description                                                                                                                                       |
| --------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `accountId*`    | integer/path  | Identifier of the account.                                                                                                                        |
| `from`          | integer/query | A Unix timestamp in milliseconds (UTC) representing the start of the date range. Operations from this time/date will be included in the response. |
| `to`            | integer/query | A Unix timestamp in milliseconds (UTC) representing the end of the date range. Operations up to this time/date will be included in the response.  |
| `numberOfLines` | integer/query | Specifies the maximum number of records to return.                                                                                                |
| `operationId`   | integer/query | The operation ID after which records will be returned.                                                                                            |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/accounts/3243563/statements?from=1701820800000" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mfhTsGNVxF72E3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0i…mP55r6pWVxvnFthJG_Cq3-cmMV-KZqvlwX2XksZxvK3542iJpr4TUPv6shbR9ltODjdyxwcORfsMeDkFUzjVIA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "d": {
    "statements": [
      [
        "Account1",
        "BRENT",
        "1713201123456",
        "P/L",
        "945265",
        "95.40",
        "96.10",
        "1713201023000",
        "7.00",
        "0.1",
        "USD",
        "4803",
        "334974",
        "683971",
        "245643",
        "232466",
        "Equity",
        "EXCHANGE",
        "1",
        "N/A"
      ],
      [
        "Account1",
        "BRENT",
        "1713202123456",
        "Fee",
        "945266",
        "97.20",
        "98.10",
        "N/A",
        "-1.25",
        "0.1",
        "USD",
        "4803",
        "334974",
        "683971",
        "245643",
        "232466",
        "Equity",
        "EXCHANGE",
        "4",
        "Commission for trade execution"
      ]
    ]
  },
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

As a result, you will receive "statements" array with operations for the specified account. The structure and order of fields in each row are defined by the headers available in the configuration `statementsConfig` section of the [Config](https://guide.traderevolution.com/traderevolution-api/traderevolution-apis/client-api/config-basic-settings-and-accesses) article.

The `amount` field in the response supports up to 8 decimal places to preserve full precision of financial operations, including those involving fractional values. Client applications consuming this API are responsible for applying any required formatting or rounding on their side, depending on their UI or business logic requirements.

Standard errors can be received as well.

{% hint style="warning" %}
The `amount` field in the response supports up to 8 decimal places to preserve full precision of financial operations, including those involving fractional values. Client applications consuming this API are responsible for applying any required formatting or rounding on their side, depending on their UI or business logic requirements.

**Position-related fields** (`openprice`, `closeprice`, `opentime`, `quantity`) are populated only for **Trading operations** (operationtypeid = 1). For other operation types, these fields will contain "N/A" or be empty.

**Commission aggregation**: Multiple commission operations per trade are aggregated into a single row with the total amount. The `accountoperationid` in such cases represents the smallest operation ID from the aggregated group.

**Swap aggregation**: Multiple swap operations for the same position on the same day are aggregated into a single row with the total amount.
{% endhint %}

{% hint style="success" %}
The method can be tested here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/getStatementReport>
{% endhint %}

## Close account request

<mark style="color:green;">`POST`</mark>`/traderevolution/v1/closeAccount`

This method is intended for account closing. The method does not require any parameters, since the user account is identified by the token, which is added to the request header. Please note that using this method you can only create a *request* for account closing, which subsequently should be applied by the admin via BackOffice: *Users -> Close account* *requests* tab.

**CURL**

{% code overflow="wrap" %}

```json
curl -X POST "https://sandbox-api.traderevolution.com/traderevolution/v1/closeAccount" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iL…BCb4B6_XgDC1W6QXtZLLFmE3sBu3S08bWedo_-Ew57s54EAYZrFvXdevy9Bm4yevUOnne5yvQk-0aPcQ" -d ""
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "requestId": 1
  }
}
```

{% endtab %}
{% endtabs %}

In response, you will get an object with the account deletion request identifier - field `requestId`.&#x20;

Standard errors can be received as well.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/createCloseAccountRequest>
{% endhint %}

## Closing request canceling

<mark style="color:red;">`DELETE`</mark>`/traderevolution/v1/closeAccountRequests/{requestId}`

This method is intended for canceling the account closing request. Note that the method requires specifying the request ID in the path (see CURL example). This ID was received after posting the account closing request.

**CURL**

{% code overflow="wrap" %}

```json
curl -X DELETE "https://sandbox-api.traderevolution.com/traderevolution/v1/closeAccountRequests/1" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW0iLC…wIbrHQgw4UrV3aeKkuW0qiQA2ziEqyPowqnLIKN0FaUEgboOfq_IfZ9b74jjATVfu0h_kEdvFJlaFisZ3Ig"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok"
}
```

{% endtab %}
{% endtabs %}

In response, you will get the “s” object only, which indicates that the request was canceled successfully - `ok`.

Standard errors can be received as well.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/cancelCloseAccountRequest>
{% endhint %}

## Withdrawal from account

<mark style="color:green;">`POST`</mark>`/traderevolution/v1/withdrawals`

This method allows you to withdraw funds from the account. Please note that the account and the amount of funds to be withdrawn are specified in the request body in this case.&#x20;

Another thing is that withdrawal may need *approval* from the admin (depending on the *Execution settings* of the server), so you will only receive a withdrawal request confirmation in the response. This confirmation will be received anyway (in case of a wrong account number, empty fields, etc.), even if the request is incorrect, this is done for security purposes.

**Body**

| Name        | Type    | Description                                                                     |
| ----------- | ------- | ------------------------------------------------------------------------------- |
| `accountId` | integer | Identifier of the account for which the withdrawal is performed.                |
| `amount`    | float   | Amount of funds to be withdrawn. Both positive and negative values are allowed. |

**Request body example**

{% tabs %}
{% tab title="Body" %}

```json
{
  "accountId": 3243563,
  "amount": 1000
}
```

{% endtab %}
{% endtabs %}

**CURL**

{% code overflow="wrap" %}

```json
curl -X POST "https://sandbox-api.traderevolution.com/traderevolution/v1/withdrawals" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcnluYW…7MPbw5tDuwO-A" -H "Content-Type: application/json" -d "{ \"accountId\": 3243563, \"amount\": 1000}"
```

{% endcode %}

**Response**

If the server accepts your request, you will receive a `200 (OK)` response without parameters. Standard errors can be received as well.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/postWithdraw>
{% endhint %}

## Pending withdrawals

<mark style="color:blue;">`GET`</mark>`/traderevolution/v1/pendingWithdrawals`

This method allows you to find out all withdrawals of the account that are not approved by the admin yet. Please note that the necessity of approving withdrawal requests is regulated at the Execution settings level of the server, so if the autoapprove is active, no pending withdrawals will be available.

**Query**

| Name        | Type    | Description                                                                 |
| ----------- | ------- | --------------------------------------------------------------------------- |
| `accountId` | integer | Identifier of the account for which pending withdrawals should be returned. |

**CURL**

{% code overflow="wrap" %}

```json
curl -X GET "https://sandbox-api.traderevolution.com/traderevolution/v1/pendingWithdrawals?accountId=3243563" -H "accept: application/json" -H "Authorization: Bearer eyJraWQiOiI3NDhlZjYwZS1mYTNlLTRmYjAtOWQyYy1kYzBhNGE3ZjZjZmEiLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpcn…uzdR-MM7HqhXSuk_CHJhrWIioAdY4Fj0uYalEZHQrD5YK3yHTDRxA2kfmCdV_tuY3zBRH2fnCb9z-PVLRD1gZF-ZkLA"
```

{% endcode %}

**Response**

{% tabs %}
{% tab title="200" %}

```json
{
  "s": "ok",
  "d": {
    "withdrawalRequests": [
      {
        "accountId": 3243563,
        "accountOperationId": 3265104,
        "amount": -10
      },
      {
        "accountId": 3243563,
        "accountOperationId": 3265103,
        "amount": -100
      }
    ]
  }
}
```

{% endtab %}
{% endtabs %}

The successful response contains the ID of the account for which there are pending withdrawals on the server, as well as the ID of the withdrawal operation and its amount.&#x20;

Standard errors can be received as well.

{% hint style="success" %}
A detailed description of this method can be found here:

<https://sandbox-api.traderevolution.com/traderevolution/v1/swagger-ui/index.html#/Account/pendingWithdrawals>
{% endhint %}
