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

The formulas behind the account summary — how collateral, equity, margin usage, and
the margin ratios are derived. For the fields as returned, see
[Get Account Summary](/latest/options/rest-api/get-account-summary) and the
[Account Summary Stream](/latest/options/websocket-api/account-summary-stream). Everything
is denominated in USDT.

## Key Definitions

| Term               | Description                                                                                                                                                  |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **accountBalance** | Settled collateral balance — the sum of every balance bucket. Unaffected by mark price movements                                                             |
| **qty**            | Signed position quantity — positive for long, negative for short                                                                                             |
| **notionalValue**  | Signed mark value of an open position — `markPrice × qty`. Returned on every position; see [Position Metrics](/latest/options/formulas/position-metrics)     |
| **positionMargin** | Initial margin locked across open positions                                                                                                                  |
| **orderMargin**    | Margin reserved for resting open orders                                                                                                                      |
| **unrealizedPnl**  | Profit or loss on open positions measured against their average entry price. Reporting only — not a term in `totalEquity`, see [Total Equity](#total-equity) |

## Account Balance

`accountBalance` accumulates settled cash flows and does not move with the mark price. The
premium you pay or receive at entry has already flowed through it.

```
accountBalance = deposits + transfersIn + premium + payoff
              - withdrawals - transfersOut - withdrawFees
              - fees - liquidationFees - profitFees - deliveryFees
```

Realized PnL and volume do not move collateral — a closed trade's cash has already moved
through `premium` and `payoff`, so they are reported for the record only.

## Total Equity

`totalEquity` is `accountBalance` plus the **signed mark value** of every open position — that
is, the sum of each position's `notionalValue`. A short's `notionalValue` is negative, so it
subtracts.

```
totalEquity = accountBalance + Σ notionalValue
            = accountBalance + Σ (markPrice × qty)
```

<Warning>
  `totalEquity` is **not** `accountBalance + unrealizedPnl`. `unrealizedPnl` is measured
  against the **entry** price, but the entry premium has already moved through
  `accountBalance` — adding that PnL back would count entry twice. Use `totalEquity`
  as published; the margin ratios are computed against it.
</Warning>

## Unrealized PnL

`unrealizedPnl` measures each open position against its average entry price and sums across
positions. It is reported on the account summary and on every position, but it is **not** the
term added to `totalEquity`.

```
unrealizedPnl = Σ (markPrice - entryPrice) × qty
```

## Available & Withdrawable Balance

`availableBalance` is the collateral free for new orders — `accountBalance` less the margin
already locked by positions and resting orders.

```
marginUsed        = positionMargin + orderMargin
availableBalance  = accountBalance - marginUsed
```

`withdrawableBalance` is the balance you can withdraw — a more conservative figure than
`availableBalance`, since unrealized profits cannot be withdrawn.

## Margin Ratios

The margin ratios divide the margin requirement by `totalEquity`. Each returns `1` when
equity is zero or negative.

```
initialMarginRatio     = marginUsed / totalEquity
maintenanceMarginRatio = maintenanceMargin / totalEquity
```

See [Margin & Fees](/latest/options/formulas/margin-and-fees) for how per-position initial and
maintenance margin are sized.

## Usage in API

These calculations back the [Get Account Summary](/latest/options/rest-api/get-account-summary)
response and the [Account Summary Stream](/latest/options/websocket-api/account-summary-stream).
`totalEquity` depends on the mark price, so it moves between balance changes; the summary is a
snapshot at the moment it is emitted. See the stream page for how to keep it current.
