# Account info

## Get full balance

### Connection

{% code title="URL" overflow="wrap" %}

```
/frontoffice/ws/v3/account?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"FullBalance"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46"
  ],
  "invocationId": "0",
  "target": "FullBalance",
  "type": 4
}
```

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

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `array of objects`

The array of balance objects.

**`item.assetId`** `string`

The asset identifier.

**`item.available`** `decimal string`

The available asset balance.

This value is calculated as *Total balance* – *Locked balance*.

**`item.total`** `decimal string`

The overall amount of the asset, including locked funds.

**`item.locked`** `decimal string`

The asset amount locked on the account for execution of all placed Limit orders.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": [
    {
      "assetId": "eur",
      "available": "497838.8",
      "total": "497838.8",
      "locked": "0"
    }
  ]
}
```

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

## Get margin data

### Connection

{% code title="URL" overflow="wrap" %}

```
/frontoffice/ws/v3/account?access_token={YOUR_ACCESS_TOKEN}
```

{% endcode %}

{% columns %}
{% column width="60%" %}
**`arguments`** `array`

The connection parameters.

In the first element, provide the `accountId` as a string.

**`invocationId`** `string`

The invocation identifier.

Must be unique and increase by 1 for each sent message.

**`target`** `string`

The stream name.

Specify `"MarginData"`.

**`type`** `int`

The operation type.

Set to `4` to indicate a subscription to the stream.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "arguments": [
    "67d0456f8c7b1108e4cf5d46"
  ],
  "invocationId": "0",
  "target": "MarginData",
  "type": 4
}
```

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

***

### Message

{% columns %}
{% column width="60%" %}
**`type`** `string`

The operation type.

`2` indicates the streaming is in progress.

**`invocationId`** `string`

The invocation identifier. Same as in the request.

**`item`** `object`

The dataset object.

**`item.marginBalanceInRAT`** `decimal string`

The total amount of funds that can be used as a collateral for trading, in RAT.

This value is calculated as SUM (*TotalAmountX* × *MarginRatioX* × *Rate X/RAT*)

Where:

* *TotalAmountX* is the the total amount of the asset X, including both available and locked funds.
* *MarginRatioX* is the Margin ratio set for the asset X.
* *Rate X/RAT* is the constantly updated rate of the asset X to the BP root asset.

**`item.unrealizedPnlInRAT`** `decimal string`

The total potential profit or loss earned from all open positions.

This value is calculated as *Σ(Unrealized PnL for Long positions + Unrealized PnL for Short positions)*, where:

* *Unrealized PnL for Long positions* = *Position size* × (*Current price* – *Open price*)
* *Unrealized PnL for Short positions* = *Position size* × (*Open price* – *Current price*)

**`item.equityInRAT`** `decimal string`

The potential balance if all open positions were closed right now.

This value is calculated as *Margin balance* + *Unrealized PnL*.

**`item.usedMarginInRAT`** `decimal string`

The amount of funds that is used for maintaining all open positions. Is opposed to the *Free margin*.

The Used margin for positions on a specific market is calculated using the maximum value between the total margin of long positions and the total margin of short positions: MAX(*MarketPositionLong*, *MarketPositionShort*).

**`item.freeMarginInRAT`** `decimal string`

The amount of funds that can be used for opening new positions.

**`item.marginLevel`** `decimal string`

The ratio of funds to a used collateral, in percents.

This value is calculated as *Equity* / *Used margin* × 100%.
{% endcolumn %}

{% column width="40%" %}
{% code title="Example" overflow="wrap" %}

```json
{
  "type": 2,
  "invocationId": "0",
  "item": {
    "marginBalanceInRAT": "497838.8",
    "unrealizedPnlInRAT": "-5.25",
    "equityInRAT": "497833.55",
    "usedMarginInRAT": "100.18",
    "freeMarginInRAT": "497733.37",
    "marginLevel": "4969.3905"
  }
}
```

{% 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/websocket-api/account-info.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.
