# Margin

## Summary

This widget helps you monitor margin parameters and statistics.

<figure><img src="https://3809883000-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5nDTeWRBfWeQuJ1QN8Tw%2Fuploads%2Fgit-blob-998829156a1e56dcd8ec101a1addf039c8561fd8%2Fwidget-margin.png?alt=media" 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.

***

**Equity**

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

This value is calculated as *Margin balance* + *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*)
