# History

## Open positions

### Get executions for an open position

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v4/positions/`<mark style="color:blue;">`{positionId}`</mark>`/executions/list`

#### Summary

Use this method to retrieve execution details for a specific open position using its position identifier.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`accountId`** <mark style="color:red;">`required`</mark>

The trading account identifier.

**Path parameters**

**`positionId`** <mark style="color:red;">`required`</mark>

The position identifier.

**Body**

**`limit`** `integer · int32 | nullable`

The maximum number of items to return.

**`offset`** `integer · int32 | nullable`

The number of items to skip before starting to collect the result set.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/positions/01K2PMT0VMJG5B8XBDNZ7FNM1F/executions/list HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
  "limit": 2,
  "offset": 0
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object containing an array of executions will be returned.

Each execution object contains the following information:

**`positionId`** `string`

The position identifier.

**`orderId`** `string`

The order identifier.

**`side`** `string`

The execution side.

Possible values:

* `Buy`
* `Sell`

**`reason`** `string`

The reason for the execution.

Possible values:

* `Trader`
* `StopOut`
* `MarketHalted`
* `MarketDisabled`
* `TakeProfit`
* `StopLoss`
* `Admin`

**`createdAt`** `string`

The date and time when the execution occurred, in the following format: `YYYY-MM-DDTHH:MM:SS.sssZ`.

**`executionId`** `string`

The execution identifier.

**`baseAmount`** `decimal string`

The executed base asset amount.

**`executionPrice`** `decimal string`

The price at which the execution was settled.

**`commissionAmountInRAT`** `decimal string`

The total commissions charged for the execution, in conversion to RAT.

**`commissions`** `array`

The breakdown of commissions charged per asset.

**`comment`** `string | nullable`

The text note attached to the order, up to 100 characters.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "executions": [
    {
      "positionId": "01K2PMT0VMJG5B8XBDNZ7FNM1F",
      "orderId": "01K2PMT0KRRMTTXGPDJCXZ99NZ",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-08-15T10:36:02.293Z",
      "executionId": "01K2PMT0VNWB23GSRN2XQAJD6Q",
      "baseAmount": "0.314",
      "executionPrice": "4603.5",
      "commissionAmountInRAT": "0",
      "commissions": [],
      "comment": null
    },
    {
      "positionId": "01K2PMT0VMJG5B8XBDNZ7FNM1F",
      "orderId": "01K2PMT0KRRMTTXGPDJCXZ99NZ",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-08-15T10:36:02.293Z",
      "executionId": "01K2PMT0VN1F2JPM14AEV6V8YJ",
      "baseAmount": "0.045",
      "executionPrice": "4603.49",
      "commissionAmountInRAT": "0",
      "commissions": [],
      "comment": null
    }
  ]
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Get executions for open positions

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v4/positions/executions/list`

#### Summary

Use this method to retrieve execution details for multiple open positions by providing an array of position identifiers.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`accountId`** <mark style="color:red;">`required`</mark>

The trading account identifier.

**Body**

**`positionIds`** `array · string[]`

The array of position identifiers.

**`limit`** `integer · int32 | nullable`

The maximum number of items to return.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/positions/executions/list HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
  "positionIds": [
    "01K2PMT0VMJG5B8XBDNZ7FNM1F",
    "01K2PMXY63HESK110WT1CHMAFA"
  ],
  "limit": 5
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object containing an array of executions will be returned.

Each execution object contains the following information:

**`positionId`** `string`

The position identifier.

**`orderId`** `string`

The order identifier.

**`side`** `string`

The execution side.

Possible values:

* `Buy`
* `Sell`

**`reason`** `string`

The reason for the execution.

Possible values:

* `Trader`
* `StopOut`
* `MarketHalted`
* `MarketDisabled`
* `TakeProfit`
* `StopLoss`
* `Admin`

**`createdAt`** `string`

The date and time when the execution occurred, in the following format: `YYYY-MM-DDTHH:MM:SS.sssZ`.

**`executionId`** `string`

The execution identifier.

**`baseAmount`** `decimal string`

The executed base asset amount.

**`executionPrice`** `decimal string`

The price at which the execution was settled.

**`commissionAmountInRAT`** `decimal string`

The total commissions charged for the execution, in conversion to RAT.

**`commissions`** `array`

The breakdown of commissions charged per asset.

**`comment`** `string | nullable`

The text note attached to the order, up to 100 characters.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "executions": [
    {
      "positionId": "01K2PMXY63HESK110WT1CHMAFA",
      "orderId": "01K2PMXY1894RC6E2BYFR00T87",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-08-15T10:38:10.627Z",
      "executionId": "01K2PMXY63NXM30VNWPDECSFJR",
      "baseAmount": "15",
      "executionPrice": "4333.69288",
      "commissionAmountInRAT": "32.27",
      "commissions": [
        {
          "assetId": "eur",
          "amount": "32.27"
        }
      ],
      "comment": null
    },
    {
      "positionId": "01K2PMT0VMJG5B8XBDNZ7FNM1F",
      "orderId": "01K2PMT0KRRMTTXGPDJCXZ99NZ",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-08-15T10:36:02.292Z",
      "executionId": "01K2PMT0VMPCZW0JB2C9J6B405",
      "baseAmount": "0.141",
      "executionPrice": "4602.3",
      "commissionAmountInRAT": "5",
      "commissions": [
        {
          "assetId": "eur",
          "amount": "5"
        }
      ],
      "comment": null
    }
  ]
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

## Closed positions

### Get orders for closed positions

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v4/orders/closed-positions`

#### Summary

Use this method to retrieve orders associated with closed positions within specified date ranges and market filters.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`accountId`** <mark style="color:red;">`required`</mark>

The trading account identifier.

**Body**

**`createdAtFrom`** `string · date-time | nullable`

The start date of the period when the positions were opened.

**`createdAtTo`** `string · date-time | nullable`

The end date of the period when the positions were opened.

**`closedAtFrom`** `string · date-time | nullable`

The start date of the period when the positions were closed.

**`closedAtTo`** `string · date-time | nullable`

The end date of the period when the positions were closed.

**`marketId`** `string | nullable`

The market identifier, in the following format: `{marketType}.{baseAssetId}_{quoteAssetId}`, for example: `cfd.eth_eur`.

**`marketType`** `string | nullable`

The market type.

Possible values:

* `Cfd`
* `Perp`

**`limit`** `integer · int32 | nullable`

The maximum number of items to return.

**`lastOrderId`** `string | nullable`

The identifier of the final order to be returned.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/orders/closed-positions HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
  "limit": 2,
  "createdAtFrom": "2025-08-01T12:00:32.886Z",
  "createdAtTo": "2025-08-15T12:00:32.886Z"
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object will be returned.

Each object contains the following information:

**`marketId`** `string`

The market identifier.

**`marketFullName`** `string | nullable`

The market full name or description (optional).

**`marketDisplayName`** `string | nullable`

The market ticker.

**`marketType`** `string`

The market type.

Possible values:

* `Cfd`
* `Perp`

**`orderId`** `string`

The order identifier.

**`orderType`** `string`

The [order type](/get-started/order-types.md).

Possible values:

* `Market`
* `Limit`

**`timeInForce`** `string`

The [time-in-force setting](/get-started/time-in-force.md) of the order.

Possible values:

* `Gtc`
* `Ioc`
* `Fok`
* `Gtd`
* `Day`

**`side`** `string`

The order side.

Possible values:

* `Buy`
* `Sell`

**`positionCloseLotAmount`** `decimal string`

The position amount closed by the order, in lots.

**`reason`** `string`

The reason for placing the order.

Possible values:

* `Trader`
* `StopOut`
* `MarketHalted`
* `MarketDisabled`
* `TakeProfit`
* `StopLoss`
* `Admin`

**`realizedPnlInRAT`** `decimal string`

The realized PnL, in conversion to RAT.

**`closedAt`** `string · date-time | nullable`

The date and time when the position was closed.

**`positionId`** `string`

The position identifier.

**`openPrice`** `decimal string`

The volume-weighted average price (VWAP) at which the position was opened.

**`closePrice`** `decimal string`

The volume-weighted average price (VWAP) of trades related to a position-closing order.

**`positionPriceInRAT`** `decimal string`

The position price, in conversion to RAT.

**`rateToRAT`** `decimal string`

The conversion rate to RAT.

**`openedAt`** `string · date-time`

The date and time when the position was opened.

**`comment`** `string | nullable`

The text note attached to the order, up to 100 characters.

**`isExceeded`** `boolean`

Indicates whether the number of returned items reached the response `limit` and more data is available.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "data": [
    {
      "marketId": "cfd.eth_eur",
      "marketFullName": null,
      "marketDisplayName": "CFD ETH/EUR",
      "marketType": "Cfd",
      "orderId": "01K2PNGX50SR1FRE6P14PJC17E",
      "orderType": "Market",
      "timeInForce": "Ioc",
      "side": "Sell",
      "positionCloseLotAmount": "15",
      "reason": "Trader",
      "realizedPnlInRAT": "-144.64",
      "closedAt": "2025-08-15T10:48:32.393Z",
      "positionId": "01K2PMXY63HESK110WT1CHMAFA",
      "openPrice": "4333.69288",
      "closePrice": "3370.58389",
      "positionPriceInRAT": "50558.75",
      "rateToRAT": "1",
      "openedAt": "2025-08-15T10:38:10.628Z",
      "comment": null
    },
    {
      "marketId": "perp.eth_usdt",
      "marketFullName": "ETH/USDT_4s8hKqiPXmXOEhsO1J6W",
      "marketDisplayName": "ETH/USDT_jC6Im5PxwgZLrwyccRcI",
      "marketType": "Perpetual",
      "orderId": "01K2PNG3N6NKAJVV4RV5E2V0HK",
      "orderType": "Market",
      "timeInForce": "Ioc",
      "side": "Sell",
      "positionCloseLotAmount": "0.5",
      "reason": "Trader",
      "realizedPnlInRAT": "13.42",
      "closedAt": "2025-08-15T10:48:06.234Z",
      "positionId": "01K2PMT0VMJG5B8XBDNZ7FNM1F",
      "openPrice": "4603.1607",
      "closePrice": "4634.3915",
      "positionPriceInRAT": "1992.78",
      "rateToRAT": "0.86",
      "openedAt": "2025-08-15T10:36:02.293Z",
      "comment": null
    }
  ],
  "isExceeded": true
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Get executions for a closing order

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v5/orders/`<mark style="color:blue;">`{orderId}`</mark>`/executions/list`

#### Summary

Use this method to retrieve execution details for a specific position-closing order using its identifier.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`accountId`** <mark style="color:red;">`required`</mark>

The trading account identifier.

**Path parameters**

**`orderId`** <mark style="color:red;">`required`</mark>

The order identifier.

**Body**

**`positionId`** `string | nullable`

The position identifier.

**`limit`** `integer · int32 | nullable`

The maximum number of items to return.

**`lastExecutionId`** `string | nullable`

The identifier of the final execution to be returned.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/orders/01K2PNG3N6NKAJVV4RV5E2V0HK/executions/list HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
  "limit": 5
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object containing an array of executions will be returned.

Each execution object contains the following information:

**`positionId`** `string`

The position identifier.

**`orderId`** `string`

The order identifier.

**`side`** `string`

The execution side.

Possible values:

* `Buy`
* `Sell`

**`reason`** `string`

The reason for the execution.

Possible values:

* `Trader`
* `StopOut`
* `MarketHalted`
* `MarketDisabled`
* `TakeProfit`
* `StopLoss`
* `Admin`

**`createdAt`** `string`

The date and time when the execution occurred, in the following format: `YYYY-MM-DDTHH:MM:SS.sssZ`.

**`executionId`** `string`

The execution identifier.

**`baseAmount`** `decimal string`

The executed amount of the base asset.

**`executionPrice`** `decimal string`

The price at which the execution was settled.

**`realizedPnlInRAT`** `decimal string`

The realized PnL, in conversion to RAT.

**`commissionAmountInRAT`** `decimal string`

The total commissions charged for the execution, in conversion to RAT.

**`commissions`** `array`

The breakdown of commissions charged per asset.

Structure:

* **`assetId`** `string`
* **`amount`** `decimal string`

**`positionSizeIncreased`** `boolean`

Indicates if a position size was increased (`true`) or decreased (`false`) as a result of the execution.

**`isExceeded`** `boolean`

Indicates whether the number of returned items reached the response `limit` and more data is available.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "executions": [
    {
      "positionId": "string",
      "orderId": "string",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-12-18T19:02:22.196Z",
      "executionId": "string",
      "baseAmount": "string",
      "executionPrice": "string",
      "realizedPnlInRAT": "string",
      "commissionAmountInRAT": "string",
      "commissions": [
        {
          "assetId": "string",
          "amount": "string"
        }
      ],
      "positionSizeIncreased": true
    }
  ],
  "isExceeded": true
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

### Get executions for closing orders

<mark style="color:blue;">`POST`</mark> `/frontoffice/api/v5/orders/executions/list`

#### Summary

Use this method to retrieve execution details for multiple position-closing orders by providing an array of order identifiers.

#### Request

{% columns %}
{% column width="60%" %}
**Header parameters**

**`accountId`** <mark style="color:red;">`required`</mark>

The trading account identifier.

**Body**

**`orderId`** `string`

The order identifier.

**`positionId`** `string`

The order identifier.
{% endcolumn %}

{% column width="40%" %}
{% code title="Request example" %}

```http
POST /frontoffice/api/v4/orders/executions/list HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
  "orderPositionPairs": [
    {
      "orderId": "01K31APDKZCVGWZA3XTF5JPAMD",
      "positionId": "01K31APDWF2EBHRKHH15VGB1ST"
    }
  ],
  "limit": 0
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}

#### Response

{% columns %}
{% column width="60%" %}
In case of success, an object containing an array of executions will be returned.

Each execution object contains the following information:

**`positionId`** `string`

The position identifier.

**`orderId`** `string`

The order identifier.

**`side`** `string`

The execution side.

Possible values:

* `Buy`
* `Sell`

**`reason`** `string`

The reason for the execution.

Possible values:

* `Trader`
* `StopOut`
* `MarketHalted`
* `MarketDisabled`
* `TakeProfit`
* `StopLoss`
* `Admin`

**`createdAt`** `string`

The date and time when the execution occurred, in the following format: `YYYY-MM-DDTHH:MM:SS.sssZ`.

**`executionId`** `string`

The execution identifier.

**`baseAmount`** `decimal string`

The executed base asset amount.

**`executionPrice`** `decimal string`

The price at which the execution was settled.

**`realizedPnlInRAT`** `decimal string`

The realized PnL, in conversion to RAT.

**`commissionAmountInRAT`** `decimal string`

The total commissions charged for the execution, in conversion to RAT.

**`commissions`** `array`

The breakdown of commissions charged per asset.

Structure:

* **`assetId`** `string`
* **`amount`** `decimal string`

**`positionSizeIncreased`** `boolean`

Indicates if a position size was increased (`true`) or decreased (`false`) as a result of the execution.

**`comment`** `string | nullable`

The text note attached to the order, up to 100 characters.

**`isExceeded`** `boolean`

Indicates whether the number of returned items reached the response `limit` and more data is available.
{% endcolumn %}

{% column width="40%" %}
{% code title="Response example — 200: OK" %}

```json
{
  "executions": [
    {
      "positionId": "string",
      "orderId": "string",
      "side": "Buy",
      "reason": "Trader",
      "createdAt": "2025-12-18T18:53:15.657Z",
      "executionId": "string",
      "baseAmount": "string",
      "executionPrice": "string",
      "realizedPnlInRAT": "string",
      "commissionAmountInRAT": "string",
      "commissions": [
        {
          "assetId": "string",
          "amount": "string"
        }
      ],
      "positionSizeIncreased": true,
      "comment": null
    }
  ],
  "isExceeded": true
}
```

{% endcode %}
{% endcolumn %}
{% endcolumns %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://api-docs.b2prime.com/rest-api/history.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
