> 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.

## 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="/trading/price-indices.md">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_{impact} = \text{Impact Price}</span> = The impact price for a bid/ask is the average execution price for a fixed impact notional, not the top-of-book quote.</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><li><span class="math">P\&#x26;L_{u,cross}</span> = Unrealized P&#x26;L on cross-margin positions</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><p><strong>Position Quantity:</strong> The position size in units of the asset (e.g. 0.01 BTC).</p><ul><li><span class="math">Q</span> = The quantity of any position</li><li><span class="math">Q_{closed}</span> = The closed quantity of any position</li></ul></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="/trading/perpetuals/funding.md">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; therefore <span class="math">L_{max} = 5</span></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 above what's required to keep an isolated position open.</li></ul></td></tr></tbody></table>

## Calculations

### Price & Value

#### Index Price

The Index Price ( $$P\_{index}$$ ) is the external spot-price anchor, from our [Index Price Sources](/trading/price-indices.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.

#### Mark Price

The Mark Price is the reference price 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 align="center"><span class="math">P_{mark} = \operatorname{median}(P_{adjusted\ index}, P_{rails\ median}, P_{index})</span></p>

Where:

<p align="center"><span class="math">P_{adjusted\ index} = P_{index}+EMA</span></p>

<p align="center"><span class="math">P_{rails\ median}=median ({Rails\ best\ bid}, {Rails\ best\ ask},{Rails\ last\ trade\ price})</span></p>

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.00000001` price increment, but displays only 6 decimals in the UI.

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

* No Rails quotes: the mark price uses the index price.
* Quotes but no trades: the mark price uses the index price while the adjustment EMA warms up.
* Quotes and at least one trade: Rails uses the full mark-price formula.
  {% endhint %}

#### Exponential Moving Average (EMA)

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

<p align="center"><span class="math">\text{Adjustment Sample} = \frac{\text{Best Bid} + \text{Best Ask}}{2} - P_{index}</span></p>

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.

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

<p align="center"><span class="math">\text{numerator} = \operatorname{round}(\text{prevNumerator} \times e^{-t / 150} + \text{adjustment sample} \times t,\ 12)</span></p>

<p align="center"><span class="math">\text{denominator} = \operatorname{round}(\text{prevDenominator} \times e^{-t / 150} + t,\ 12)</span></p>

<p align="center"><span class="math">\text{EMA} = \frac{\text{numerator}}{\text{denominator}}</span></p>

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

#### Entry & Exit Price

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.

#### Average Price

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

<p align="center"><span class="math">P_{avg} = \frac{\text{Position Value}}{Q}</span></p>

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.

#### Notional Value

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

<p align="center"><span class="math">\text{Notional Value} = P_{mark} \times Q</span></p>

#### Position Value

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

<p align="center"><span class="math">\text{Position Value} = P_{entry} \times Q</span></p>

#### Impact Price

Impact bid or ask price is the average execution price for trading a fixed [impact notional](#impact-notional) against the order book.

* **Impact Ask** is the average price to buy that notional from asks.
* **Impact Bid** is the average price to sell it into bids.
* **Impact Mid** is their midpoint.

Unlike the best bid/ask, impact prices reflect liquidity at meaningful size. They diverge from top-of-book quotes when available depth is limited. Impact Price is used in [funding calculations](/trading/perpetuals/funding.md) for Perps.

#### Impact Notional

$$
\text{Impact Notional} = 100 \text{ USDT} \times L\_{max}
$$

#### Withdrawal Fee

Rails deducts a withdrawal fee to cover network costs when you withdraw amounts from the platform, calculated as:

$$
Fee\_{wd} = \min(0.001 \times \text{Withdrawal Amount},\ 1)
$$

The fee is 0.1% of the amount you withdraw, up to a maximum of $1 per withdrawal. The covers the network costs - like gas fees - we pay to process your withdrawal. It isn’t a Rails platform fee.

#### Liquidation Fee

If a position is liquidated, Rails charges a liquidation fee of 1% of the liquidated value, calculated as:

$$
Fee\_{liq} = 0.01 \times \text{Liquidated Value}
$$

### Balance and P\&L

#### Available Balance

Available Balance shows the funds available to open new positions. Your [withdrawable balance](#withdrawable-balance) may be lower. 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}
$$

#### Total Balance

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

<p align="center"><span class="math">\text{Total Balance} = D_{total} - W_{total} + P\&#x26;L_{r,total} -Fees_{total} +F_{total}</span></p>

#### Withdrawable Balance

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.

<p align="center"><span class="math">\text{Withdrawable Balance} =\text{Total Balance} + \sum \min(0, P\&#x26;L_{u}) - \sum \left(P_{entry} \times \frac{\lvert Q \rvert}{L}\right) - \text{Open Order Margin}</span></p>

#### Cross-Margin Balance

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.

<p align="center"><span class="math">\text{Cross-Margin Balance} = \text{Total Balance} - \text{Isolated Position Margin}</span></p>

#### Unrealized P\&L

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 align="center"><span class="math">P\&#x26;L_{u} = (P_{mark} - P_{avg}) \times S \times Q</span></p>

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

#### Realized P\&L

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 align="center"><span class="math">P\&#x26;L_{r} = (P_{exit} - P_{avg}) \times S \times Q_{closed}</span></p>

### Equity & Margin

{% hint style="info" %}
Learn about how these fields impact your account in the [risk management overview](/trading/perpetuals/margin-leverage-and-liquidation.md).
{% endhint %}

#### Account Equity

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

<p align="center"><span class="math">\text{Account Equity} = \text{Total Balance} +P\&#x26;L_{u,total}</span></p>

#### Cross-Margin Equity

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.

<p align="center"><span class="math">\text{Cross-Margin Equity} = \text{Cross-Margin Balance} + P\&#x26;L_{u,cross}</span></p>

{% 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 %}

#### Isolated Position Equity

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:

<p align="center"><span class="math">\text{Isolated Position Equity}=\text{Isolated Position Margin }+P\&#x26;L_{u,position}</span></p>

#### Maintenance Margin Rate (or MMR)

Maintenance Margin Rate (or MMR) is a fixed 5% buffer added to all positions for market volatility and [slippage](/support/troubleshooting-guide.md#what-is-slippage-and-why-does-it-happen).

<p align="center"><span class="math">\text{MMR} = 0.05</span></p>

#### Maintenance Margin

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:

<p align="center"><span class="math">\text{Maintenance Margin}_\text{position} = P_{mark} \times \lvert Q \rvert \times \text{MMR}</span></p>

#### Total Cross Maintenance Margin

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

<p align="center"><span class="math">\text{Total Cross Maintenance Margin} = \sum \text{Maintenance Margin}_{\text{position, cross}}</span></p>

#### Available Margin

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, and depends on your margin mode:

In **cross-margin mode**, the following is calculated across all cross-margin positions:

$$
\text{Available Margin} = \text{Cross Margin Equity − Total Cross Maintenance Margin}
$$

In **isolated margin mode**, the following is calculated for each specific position only:

$$
\text{Available Margin = Isolated Position Equity - Maintenance Margin}
$$

#### Position Margin & Open Order Margin

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.

<p align="center"><span class="math">\text{Position Margin} = P_{mark} \times \frac{\lvert Q \rvert}{L}</span></p>

#### Required Margin

Required Margin is the minimum margin requirement for an isolated position. This floor ensures the position retains enough collateral to remain open at the current leverage.

<p align="center"><span class="math">M_{req} = P_{mark} × \frac{|Q|}{L}</span></p>

#### Excess Margin

Excess Margin is the extra collateral above the required margin that you can remove from an isolated position without immediately breaking the minimum margin needed to keep the position open.

<p align="center"><span class="math">M_{excess} = \max(0, M_{p,iso} + \min(0, P\&#x26;L_{u}) - M_{req})</span></p>
