> For the complete documentation index, see [llms.txt](https://help.rails.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.rails.xyz/trading/perpetuals/perps-metrics-guide.md).

# Perps Metrics Guide

This guide explains the main metrics on Rails and how they are calculated.

<table data-view="cards"><thead><tr><th align="center"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td align="center"><strong>Definitions</strong></td><td><a href="/pages/mrhZMXf6H54XlRMJrXhY#definitions">/pages/mrhZMXf6H54XlRMJrXhY#definitions</a></td></tr><tr><td align="center"><strong>Calculations: Price &#x26; Value</strong></td><td><a href="/pages/mrhZMXf6H54XlRMJrXhY#price-and-value">/pages/mrhZMXf6H54XlRMJrXhY#price-and-value</a></td></tr><tr><td align="center"><strong>Calculations: Balance &#x26; P&#x26;L</strong></td><td><a href="/pages/mrhZMXf6H54XlRMJrXhY#balance-and-p-and-l">/pages/mrhZMXf6H54XlRMJrXhY#balance-and-p-and-l</a></td></tr><tr><td align="center"><strong>Calculations: Equity &#x26; Margin</strong></td><td><a href="/pages/mrhZMXf6H54XlRMJrXhY#equity-and-margin">/pages/mrhZMXf6H54XlRMJrXhY#equity-and-margin</a></td></tr><tr><td align="center"><strong>Calculations: Liquidation</strong></td><td><a href="/pages/mrhZMXf6H54XlRMJrXhY#liquidation">/pages/mrhZMXf6H54XlRMJrXhY#liquidation</a></td></tr></tbody></table>

## Definitions

<table><thead><tr><th width="100.6488037109375" align="center">Symbol</th><th>Meaning</th></tr></thead><tbody><tr><td align="center"><span class="math">P</span></td><td><p><strong>Price:</strong> The price in USDT, where:</p><ul><li><span class="math">P_{index} = \text{Index Price}</span> = the external spot price from our <a href="/pages/QLMYpTm831YuVLgLZnGI">Index Price sources</a>.</li><li><span class="math">P_{mark} = \text{Mark Price}</span> = the risk reference for perpetuals. It determines unrealized P&#x26;L, margin requirements, and liquidations.</li><li><span class="math">P_{rails\ median}</span> = the median of Rails’ best bid, best ask, and last trade.</li><li><span class="math">P_{adjusted\ index}</span> = The index price plus the exponential moving average (EMA) of the adjustment.</li><li><span class="math">P_{entry} = \text{Entry Price}</span></li><li><span class="math">P_{avg} = \text{Average Entry Price}</span></li><li><span class="math">P_{exit} = \text{Exit Price}</span></li></ul></td></tr><tr><td align="center"><span class="math">P\&#x26;L</span></td><td><p><strong>Profit &#x26; Loss:</strong> How much in USDT gained (profit) or lost (loss) compared to the entry price and position size, where:</p><ul><li><span class="math">P\&#x26;L_{u}</span> = Unrealized P&#x26;L</li><li><span class="math">P\&#x26;L_{r}</span> = Realized P&#x26;L</li></ul></td></tr><tr><td align="center"><span class="math">S</span></td><td><p><strong>Position Side</strong>: The side of your position, where:</p><ul><li><span class="math">S_{long}=1</span></li><li><span class="math">S_{short}=-1</span></li></ul></td></tr><tr><td align="center"><span class="math">Q</span></td><td><strong>Position Quantity:</strong> The position size in units of the asset (e.g. 0.01 BTC).</td></tr><tr><td align="center"><span class="math">Fees</span></td><td><strong>Trading Fees:</strong> Total entry and exit fees in USDT.</td></tr><tr><td align="center"><span class="math">F</span></td><td><strong>Funding Payments:</strong> Can be positive or negative, and are transferred between traders. Funding uses the index price. Funding payments are not fees charged by Rails. Learn about the funding mechanism in perpetuals <a href="/pages/Pax0Kc9HJbgr25Tj3p2b">here</a>.</td></tr><tr><td align="center"><span class="math">D</span></td><td><strong>Deposits</strong>: Amount of USDT deposited to your account</td></tr><tr><td align="center"><span class="math">W</span></td><td><strong>Withdrawals</strong>: Total USDT withdrawal volume</td></tr><tr><td align="center"><span class="math">L</span></td><td><strong>Leverage:</strong> The per-market leverage used, between 1x - 5x.</td></tr><tr><td align="center"><span class="math">V</span></td><td><strong>Notional Position Value</strong></td></tr><tr><td align="center"><span class="math">M</span></td><td><p><strong>Margin:</strong> the portion of your funds set aside to support a trade. It acts as collateral for open positions and open orders, where:</p><ul><li><span class="math">M_{p,cross} = \text{Cross Position Margin}</span> = margin locked by your open cross margin positions</li><li><span class="math">M_{p,iso} = \text{Isolated Position Margin}</span> = margin already allocated to all isolated positions</li><li><span class="math">M_{total,open orders} = \text{Total Open Order Margin}</span> = margin reserved for all open, unfilled orders</li><li><span class="math">M_{req} = \text{Margin Required}</span> = Margin Required to keep your positions open</li><li><span class="math">M_{excess} = \text{Excess Margin}</span> = Margin available to place orders. Only excess margin is withdrawable.</li></ul></td></tr></tbody></table>

## Calculations

### Price & Value

<details>

<summary>Index Price</summary>

The **Index Price** is the external spot-price anchor, from our [Index Price Sources](/trading/index-price-sources.md).

Rails uses the Index Price to calculate [funding](/trading/perpetuals/funding.md), and to keep the [mark price](#mark-price) aligned with the broader market.

</details>

<details>

<summary>Exponential Moving Average (EMA)</summary>

Rails’ market can trade slightly above or below the index price. This difference is the **adjustment**:

$$\text{Adjustment Sample} = \frac{\text{Best Bid} + \text{Best Ask}}{2} - P\_{index}$$

The adjusted index uses an EMA of this adjustment. The EMA has a 2.5-minute time constant. Recent samples carry more weight, while older samples fade smoothly.

This smoothing limits the effect of brief order-book changes. A one-second spike barely affects the EMA. A persistent adjustment shifts it over several minutes.

**EMA calculation**

Rails updates the EMA on every tick. Let `t` be the seconds since the prior update:

$$\text{numerator} = \operatorname{round}(\text{prevNumerator} \times e^{-t / 150} + \text{adjustment sample} \times t,\ 12)$$

$$\text{denominator} = \operatorname{round}(\text{prevDenominator} \times e^{-t / 150} + t,\ 12)$$

$$\text{EMA} = \frac{\text{numerator}}{\text{denominator}}$$

Each sample is weighted by how long it remained in effect. Rails rounds the numerator and denominator to 12 decimal places after each update.

The adjusted index price is:

$$P\_{adjusted\ index} = P\_{index} + \text{EMA}$$

</details>

<details>

<summary>Mark Price</summary>

The **Mark Price** is Rails’ risk reference for a perpetual market. It determines unrealized P\&L, margin requirements, liquidation prices, and liquidation triggers.

The mark price uses the median of three values:

$$P\_{mark} = \operatorname{median}(P\_{adjusted\ index}, P\_{rails\ median}, P\_{index})$$

This approach limits the impact of short-lived order-book moves. A sustained difference between Rails’ market and the index can influence the mark price gradually.

Market orders, take-profit and stop-loss triggers, and limit-price safety checks use the mark price as their reference.

{% hint style="info" %}

#### **Availability and updates**

Rails publishes mark-price updates on each index-price tick, at most once every 250 milliseconds per market. Rails uses exact decimal arithmetic and rounds each published price to the `0.0000001` price increment.

If a market is missing a required Rails input, the mark price falls back to the index price:

* **No Rails quotes:** the order book is empty.
* **Quotes but no trades:** the adjustment EMA continues warming from quotes.
* **Quotes and trades:** Rails uses the full mark-price formula.
  {% endhint %}

</details>

<details>

<summary>Entry Price/Exit Price</summary>

The Entry Price is the price at which your order was filled to open a position. The Exit Price is the price at which your order was filled to close your position.

</details>

<details>

<summary>Average Price</summary>

The **Average Price** shown in your account is the *adjusted weighted average entry price* of your open position, calculated as:

$$P\_{avg} = \frac{\text{Position Value}}{Q}$$

When you add to a position, every new trade that increases its size is added to the weighted average. This gives you one entry price that reflects the full open position.

When you partially close a position:

1. The system realizes profit or loss on the part you closed.
2. It subtracts any trading fees and, if applicable, funding charges.
3. It then recalculates the average entry price for the remaining position.

This keeps your unrealized P\&L aligned with the position still open.

Because realized PnL and fees are included, your displayed average price can change slightly after a partial close. This does not mean your trade executed at a different price. It means the platform adjusted the remaining position to account for PnL already realized.

</details>

<details>

<summary>Notional Value</summary>

**Notional Value** is the current market value of your position based on the index price:

$$\text{Notional Value} = P\_{index} \times Q$$

</details>

<details>

<summary>Position Value</summary>

**Position Value** is the total notional value, or exposure, of your trade based on the entry price used to open the position:

$$\text{Position Value} = P\_{entry} \times Q$$

</details>

### Balance and P\&L

<details>

<summary>Available Balance</summary>

**Available Balance** is the amount you have available to place new trades, and fluctuates as the market moves. Margin calculations can be found [here](#equity-and-margin).

$$\text{Available Balance} = \text{Cross Margin Equity} - \text{Cross Position Margin} - \text{Total Open Order Margin}$$

</details>

<details>

<summary>Total Balance</summary>

Total Balance is the settled cash value of your account. It reflects completed events, but does not include unrealized P\&L from open positions:

$$\text{Total Balance} = D\_{total} - W\_{total} + P\&L\_{r,total} -Fees\_{total} +F\_{total}$$

</details>

<details>

<summary>Withdrawable Balance</summary>

**Withdrawable Balance** represents the portion of your account balance that can be withdrawn. Margin for open positions and orders reduces this amount. Unrealized losses, based on mark price, also reduce it. To increase your withdrawable balance, you should partially or fully close an open position with positive unrealized P\&L to realize profits.

$$\text{Withdrawable Balance} = \text{Total Balance} + \sum (min(0,(P\_{mark}-P\_{entry})\times Q \times S)) - \sum (P\_{mark} \times \frac{Q}{L}) - \text{Open Order Margin}$$

</details>

<details>

<summary>Cross-Margin Balance</summary>

**Cross-Margin Balance** is the base balance available for your cross-margin pool. It equals your settled total balance minus collateral locked in isolated margin positions.

$$\text{Cross-Margin Balance} = \text{Total Balance} - \text{Isolated Position Margin}$$

</details>

<details>

<summary>Unrealized P&#x26;L</summary>

**Unrealized P\&L** reflects the profit or loss if a position were closed at the current mark price. The account summary displays the total unrealized P\&L for all positions.

$$P\&L\_{u} = (P\_{mark} - P\_{avg}) \times S \times Q$$

{% hint style="warning" %}
Unrealized P\&L uses the mark price, not the order-book price.
{% endhint %}

</details>

<details>

<summary>Realized P&#x26;L</summary>

**Realized P\&L** reflects the profit or loss realized through closed positions. Once a position is closed, the realized P\&L is computed and added to the Account Summary.

$$P\&L\_{r} = (P\_{exit} - P\_{entry}) \times S \times Q - Fees + F$$

</details>

### Equity & Margin

{% hint style="info" %}
Visit our [Margin Modes Guide](/trading/perpetuals/margin-modes.md) for more information.
{% endhint %}

<details>

<summary>Account Equity</summary>

**Account Equity** is the current live balance of your account. It changes as mark-price movements affect unrealized P\&L.

$$\text{Account Equity} = \text{Total Balance} +P\&L\_{u,total}$$

</details>

<details>

<summary>Cross-Margin Equity</summary>

**Cross-Margin Equity** is the total value of your shared collateral pool. It changes with the unrealized P\&L of your open cross-margin positions.

$$\text{Cross-Margin Equity} = \text{Cross-Margin Balance} + P\&L\_{u,total}$$

{% hint style="info" %}
Unrealized P\&L is aggregated across all open cross-margin positions. As the market moves, your cross-margin equity updates continuously.
{% endhint %}

</details>

<details>

<summary>Isolated Position Equity</summary>

In **Isolated Margin** Mode, each position has its own dedicated margin pool and is excluded from the cross-margin pool. **Isolated Position Equity** is calculated as:

$$\text{Isolated Position Equity}=\text{Isolated Position Margin }+P\&L\_{u,position}$$

</details>

<details>

<summary>Maintenance Margin Ratio (or MMR)</summary>

**Maintenance Margin Ratio (or MMR)** is a fixed 5% buffer added to all positions for market volatility and [slippage](https://help.rails.xyz/rails/trading/leverage-and-liquidation#what-is-slippage-and-why-does-it-happen).

$$\text{MMR} = 0.05$$

</details>

<details>

<summary>Maintenance Margin</summary>

Each open position requires a minimum amount of equity to remain open, referred to as **Maintenance Margin**. The maintenance margin uses the current mark price:

$$\text{Maintenance Margin}*\text{position} = P*{mark} \times Q \times \text{MMR}$$

</details>

<details>

<summary>Total Maintenance Margin</summary>

In cross-margin, the **Total Maintenance Margin** is the sum of maintenance margins across all open positions.

$$\text{Total Maintenance Margin} = \sum \text{Maintenance Margin}\_{\text{position}}$$

</details>

<details>

<summary>Available Margin</summary>

**Available Margin** is the amount of funds available to support your open positions after required margin is accounted for. It shows the remaining buffer before liquidation risk increases.

$$\text{Margin Available = Account Equity - }\sum(\text{Maintenance Margin})$$

</details>

<details>

<summary>Position Margin &#x26; Open Order Margin</summary>

**Position Margin** is the margin calculated per open position based on the current mark price. Your selected leverage also affects it. **Open Order Margin** uses the same reference price and affects your available collateral.

$$\text{Position Margin} = P\_{mark} \times \frac{Q}{{L}}$$

</details>

<details>

<summary>Excess Margin</summary>

**Excess Margin** is the extra collateral above the required margin that you can remove (isolated) or withdraw (cross) without immediately breaking the minimum margin needed to keep the position open.

$$M\_{excess} = M\_{p,iso} - M\_{req}$$

</details>

<details>

<summary>Effective Leverage</summary>

**Effective Leverage** is the actual leverage applied to an open position. It may differ from the leverage you initially selected due to price movements, fees, or margin adjustments between order placement and trade execution.

$$\text{Effective Leverage} = \frac{\text{Total Position Value}}{\text{Total Available Balance}}$$

</details>

<details>

<summary>Cross Leverage</summary>

**Cross Leverage** reflects the total size of your open positions relative to your margin available, showing how much risk you are taking across all trades combined. It aggregates the effective leverage from all open positions into a single number, showing your total risk exposure.

$$\text{Cross Leverage} = \frac{\text{Total Positions}}{\text{Account Balance}}$$

</details>

### Liquidation

{% hint style="info" %}
Visit the [Liquidation](/trading/perpetuals/liquidation.md) page for a more in-depth explanation of liquidation triggers and mechanics.
{% endhint %}

<details>

<summary>Cross-Margin Ratio</summary>

**Cross-Margin Ratio** measures overall account health. It shows what percentage of account equity is consumed by minimum margin requirements across all open positions.

$$\text{Cross-Margin Ratio} = \frac{\text{Total Maintenance Margin}}{\text{Account Equity}}$$

<table><thead><tr><th width="183.03515625">Cross-Margin Ratio</th><th>Status</th></tr></thead><tbody><tr><td>&#x3C; 100%</td><td>Healthy</td></tr><tr><td>≥ 100%</td><td>Liquidation triggered - all positions closed</td></tr></tbody></table>

</details>

<details>

<summary>Simulated Cross-Margin Ratio</summary>

Simulated Cross-Margin Ratio checks whether your open orders would make your account too risky. If the ratio reaches 90%, the system *cancels any qualifying orders before they execute*. Instead of waiting until after an order fills, the platform estimates risk as the order book changes. This *protects your account from the risk of an immediate post-fill liquidation*.

**Simulated Cross-Margin Ratio** is calculated by assuming all eligible open orders are filled:

<p align="center"><span class="math">\text{Simulated Cross-Margin Ratio} = \frac {\text{Simulated Maintenance Margin}}{\text{Cross Margin Equity}}</span></p>

and

<p align="center"><span class="math">\text{Simulated Maintenance Margin} = \text{Position Maintenance Margin } + (\text{Selected Order Value} \times MMR)</span></p>

Where:

* $$\text{Position Maintenance Margin}$$ = the maintenance margin required for your current open positions.
* $$\text{Selected Order Value}$$ = the notional value of open orders that would *increase* your net position exposure.

</details>

<details>

<summary>Liquidation Price</summary>

**Liquidation Price** is the mark price at which liquidation may occur:

$$\text{Liquidation Price} = P\_{index} - \frac{{S} \times \text{Available Margin}}{\left|\text{Q}\right| \times \left(1 - \text{MMR} \times S\right)}$$

Where $$\text{Available Margin}$$ is dependent on Margin Mode Used:

* In Cross-Margin, $$\text{Available Margin} = \text{Cross Margin Balance} - \text{Total Cross Maintenance Margin}$$
* In Isolated Margin: $$\text{Available Margin} = \text{Isolated Position Equity} - \text{Maintenance Margin}\_{position}$$

{% hint style="info" %}
Note: If the liquidation price of your position is less than or equal to zero, no liquidation price is displayed.
{% endhint %}

</details>
