> For the complete documentation index, see [llms.txt](https://trader-docs.b2trader.b2broker.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trader-docs.b2trader.b2broker.com/widgets/margin.md).

# Margin

## Summary

This widget helps you monitor margin parameters and statistics.

<figure><img src="/files/7HB7vi5A5qNVXn6ch5Fi" alt="Margin"><figcaption><p>Margin</p></figcaption></figure>

## Fields

All values are in displayed in conversion to the platform root asset:

**Your margin level**

The ratio of your funds to a used collateral, in percents. This value is calculated as *Equity* / *Used margin* × 100%.

Possible values:

* **Empty**: No open positions.
* **Low risk**: Everything is ok.
* **Margin call**: Your margin level fell below the set Margin call value. You received a notification urging you to increase the margin level to avoid a Stop out. Remember that if you ignore this warning, the margin level may continue to decrease. During the Margin call, you can only close existing positions; opening new positions isn’t possible.
* **Stop out level**: Your margin level fell below the set Stop out value; the platform started a process of liquidating your positions. This process continues until the margin level exceeds this required value. **ANY** currently open position can be closed regardless of its side and volume.

***

**Margin balance**

The total amount of your funds that can be used as a collateral for CFD trading.

It’s calculated as Σ(*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 platform root asset.

The Margin balance is continually recalculated based on price fluctuations. An increase in the prices of assets boosts available Balance & Free margin. Conversely, a decrease in asset prices may reduce the available Balance and Free margin. Additionally, a decline in the prices of assets with open positions may trigger Margin calls and Stop outs.

***

**Credit**

A promotional bonus granted by your broker for margin (CFD and Perpetual) trading, shown in the platform root asset (RAT). When you have no credit, this row shows 0.

Credit increases your Equity and Free margin and can be used as collateral to open positions. It becomes available immediately when granted and never expires. However, credit cannot be withdrawn as cash, so it is excluded from your withdrawable balance. Your broker can revoke credit at any time, and the row updates in real time when this happens.

The row includes an info tooltip that reads: *Promotional credit for margin trading only. Cannot be withdrawn.*

***

**Equity**

The potential balance of your account if all your positions were closed right now.

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

***

**Used margin**

The amount of funds that is used for maintaining all your 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*).

**Example**

**Step 1: Initial balance**

* Margin balance: $10,000
* Opened positions: 0
* Free margin: $10,000
* Used margin: $0

**Step 2: Open a long position (Leverage 1:100)**

* Market: CFD EUR/USD
* Position size: 1 lot (100,000 units)
* Current price: $1.001
* Required margin: $(100,000 × 1.001) / 100 = $1,001
* After opening:
  * Free margin: $8,999
  * Used margin: $1,001

**Step 3: Open a long position (Leverage 1:20)**

* Market: CFD EUR/USD
* Position size: 1 lot (100,000 units)
* Current price: $1.001
* Required margin: $(100,000 × 1.001) / 20 = $5,005
* After opening:
  * Free margin: $3,994
  * Used margin: $6,006

**Step 4: Open a short position (Leverage 1:100)**

* Market: CFD EUR/USD
* Position size: 9 lots (900,000 units)
* Current price: $1
* Required margin: $(900,000 × 1.001) / 100 = $9,009.

The system verifies that upon opening this position, the MarketUsedMargin remains valid by satisfying the condition: **MarketUsedMargin** = MAX(*MarketPositionLong*, *MarketPositionShort*) = MAX(6,006, 9,009) = 9,009. Since the condition is met, the position opens.

* After opening:
  * Free margin: $991
  * Used margin: $9,009

As a result, you can open multiple opposite positions without significantly increasing the Used margin. Furthermore, closing positions never increases the Used margin.

***

**Free margin**

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

***

**Unrealized PnL**

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*)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://trader-docs.b2trader.b2broker.com/widgets/margin.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.
