> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rails.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Account Equity & Balances

In our trading system, account balances aggregate settled cash activity and open position metrics to reflect your real-time financial state. Balances are split across two collateral pools — **cross margin** (shared across all cross positions) and **isolated margin** (dedicated to a single position) — and several balance views are derived from them.

## Key Definitions

| Term                       | Description                                                                                                                                                                                                                                                              |
| -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **totalBalance**           | Settled cash balance — unaffected by index price movements                                                                                                                                                                                                               |
| **crossMarginBalance**     | Portion of `totalBalance` available as collateral for cross margin positions (i.e. excluding margin locked in isolated positions)                                                                                                                                        |
| **isolatedPositionMargin** | Margin allocated to an isolated position; for the whole account, the sum across all isolated positions                                                                                                                                                                   |
| **unrealizedPnL**          | Unrealized profit or loss. For cross margin metrics, use the sum across all cross margin positions. For isolated position metrics, use only that position's `unrealizedPnl` (see [Unrealized PnL](/latest/position-metrics#unrealized-pnl) for the per-position formula) |
| **crossMarginEquity**      | `crossMarginBalance + unrealizedPnL` across all cross margin positions                                                                                                                                                                                                   |
| **isolatedPositionEquity** | `isolatedPositionMargin + unrealizedPnL` for a single isolated position                                                                                                                                                                                                  |
| **positionMargin**         | Collateral locked per open position, calculated from the current index price                                                                                                                                                                                             |
| **openOrderMargin**        | Collateral reserved for open (unfilled) orders                                                                                                                                                                                                                           |

## Total Balance

Total balance accumulates all settled cash flows and does not fluctuate with index price movements.

```
totalBalance = deposits - withdrawals + realizedPnL - fees + fundingPayments
```

## Cross Margin Balance

Cross margin balance is the portion of `totalBalance` available as collateral for cross margin positions. Margin allocated to isolated positions is excluded.

```
crossMarginBalance = totalBalance - isolatedPositionMargin  -- across all isolated positions
```

When an isolated position is opened or increased, the order margin moves out of `crossMarginBalance` into `isolatedPositionMargin`. Partially closing an isolated position releases the corresponding proportion (plus realized PnL) back to `crossMarginBalance`.

## Cross Margin Equity

Cross margin equity includes unrealized PnL from all cross margin positions, so it fluctuates in real time as the index price moves. It is the figure used in the [Cross Margin Ratio](#cross-margin-ratio).

```
crossMarginEquity = crossMarginBalance + unrealizedPnL  -- across all cross margin positions
```

## Isolated Position Equity

For an isolated position, equity is self-contained — only that position's margin and unrealized PnL contribute. It is the figure used to evaluate liquidation for the isolated position.

```
isolatedPositionEquity = isolatedPositionMargin + unrealizedPnL  -- for that position only
```

## Cross Margin Ratio

The cross margin ratio measures the health of your cross margin pool — what percentage of cross margin equity is consumed by maintenance margin requirements across all cross margin positions. Isolated positions are excluded from this calculation.

```
crossMarginRatio = totalCrossMaintenanceMargin / crossMarginEquity

where:
  totalCrossMaintenanceMargin = SUM(indexPrice × ABS(positionQty) × MMR)  -- across all cross margin positions
  crossMarginEquity           = crossMarginBalance + unrealizedPnL        -- across all cross margin positions
```

See [Maintenance Margin](/latest/position-metrics#position-margin--maintenance-margin) for the per-position formula.

| Cross Margin Ratio | Account Status                                            |
| ------------------ | --------------------------------------------------------- |
| \< 100%            | Healthy — positions are safe                              |
| ≥ 100%             | Liquidation triggered — all cross margin positions closed |

## Simulated Cross Margin Ratio

Rails also computes a simulated ratio assuming all qualifying open orders are executed. This drives the [Proactive Order Cancellation](/latest/platform-overview/risk-management#proactive-order-cancellation) mechanism. The simulation includes position-increasing orders on both cross and isolated margin positions, with different effects on the ratio:

* Cross margin orders increase simulated maintenance margin.
* Isolated margin orders reduce simulated cross margin equity because filling them moves margin out of `crossMarginBalance`.

```
simulatedCrossMarginRatio = simulatedMaintenanceMargin / simulatedCrossMarginEquity

where:
  simulatedMaintenanceMargin  = totalCrossMaintenanceMargin + (crossSelectedOrderValue × MMR)
  simulatedCrossMarginEquity  = crossMarginEquity - isolatedSelectedOrderMargin
  crossSelectedOrderValue     = notional value of cross margin orders that would increase net position exposure
  isolatedSelectedOrderMargin = order margin required by isolated margin orders that would increase net position exposure
```

| Simulated Cross Margin Ratio | Action                                    |
| ---------------------------- | ----------------------------------------- |
| \< 90%                       | No action                                 |
| ≥ 90%                        | Risk-increasing open orders are cancelled |

## Available Balance

Available balance is the amount free for new orders or withdrawals. It deducts cross position margin (computed at the current index price) and open order margin from cross margin equity. Isolated positions are excluded — their margin is already deducted via `crossMarginBalance`.

```
availableBalance = crossMarginEquity - crossPositionMargin - openOrderMargin

where:
  crossPositionMargin = SUM(indexPrice × ABS(positionQty) / leverage)  -- across all cross margin positions
  openOrderMargin     = margin reserved for all resting open orders
```

## Withdrawable Balance

Withdrawable balance is a more conservative measure than available balance. Unrealized profits cannot be withdrawn — only realized gains contribute. Unrealized losses reduce the withdrawable balance immediately, and margin is locked at the entry price rather than the current index price.

```
withdrawableBalance = totalBalance
                    + SUM(MIN(0, unrealizedPnL))          -- unrealized losses only
                    - SUM(entryPrice × ABS(positionQty) / leverage)  -- margin locked at entry price
                    - openOrderMargin
```

The sums above span all open positions — both cross and isolated. Withdrawable balance is a single account-wide figure and is not split by margin mode.

## Usage in API

These calculations are used in the [Get Account Balances](/latest/rest-api/get-account-balances) response. `totalBalance` and `crossMarginBalance` are returned at the top level; each market's `marginMode` (`C` or `I`) is reported under `marketBalancesMap`.

Use the returned balance and position fields to derive equity by margin mode:

* Derive `crossMarginEquity` by adding `crossMarginBalance` to the sum of `unrealizedPnl` for markets where `marginMode` is `C`.
* Derive `isolatedPositionEquity` for an isolated market by adding that market's `margin` to that market's `unrealizedPnl` where `marginMode` is `I`.

The top-level `margin` field in the balances response represents the total position margin in use across all markets.
