---
title: "Sub account summary"
description: "Get one sub-account's balances, positions, margin and P\u0026L."
---

| | |
|---|---|
| SDK | `client.sub_account_summary(...)` |
| HTTP | `POST https://trades.<domain>/full/v1/account_summary`, or `/lite/v1/account_summary` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v1/account_summary` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Retries | Read: the SDKs retry retryable errors ([rules](../../guides/errors-and-retries.md)) |
| Contract id | `account.sub_account_summary` (`RPCSubAccountSummaryV1`) |

## Request

Body type `ApiSubAccountSummaryRequest`. Fields the server fills are left out.

- `sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID to filter by

## Response

Body type `ApiSubAccountSummaryResponse` (the same object is the JSON-RPC `result` over WebSocket).

- `result` · lite `r` · object SubAccount · required — The sub-account matching the request sub-account
- `result.event_time` · lite `et` · string (int64 unix ns) · required — Time at which the event was emitted in unix nanoseconds
- `result.sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID this entry refers to
- `result.margin_type` · lite `mt` · enum MarginType · required — The type of margin algorithm this sub-account uses
  Values: `SIMPLE_CROSS_MARGIN`, `PORTFOLIO_CROSS_MARGIN` ([details](../enums.md#margintype)).
- `result.settle_currency` · lite `sc` · string · required — The settlement, margin, and reporting currency of this account.
  This sub-account can only open positions quoted in this currency

  In the future, when users select a Multi-Currency Margin Type, this will be USD
  All other assets are converted to this currency for the purpose of calculating margin
- `result.unrealized_pnl` · lite `up` · string · required — The total unrealized PnL of all positions owned by this sub-account, in the quote asset. Decimal string, e.g. "12.5".
  `unrealized_pnl = sum(position.unrealized_pnl * position.quote_index_price) / settle_index_price`
- `result.total_equity` · lite `te` · string · required — The notional value of your account if all positions are closed, excluding trading fees (reported in `settle_currency`).
  `total_equity = sum(spot_balance.balance * spot_balance.index_price) / settle_index_price + unrealized_pnl`
- `result.initial_margin` · lite `im` · string · required — The `total_equity` required to open positions in the account (reported in `settle_currency`).
  Computation is different depending on account's `margin_type`
- `result.maintenance_margin` · lite `mm` · string · required — The `total_equity` required to avoid liquidation of positions in the account (reported in `settle_currency`).
  Computation is different depending on account's `margin_type`
- `result.available_balance` · lite `ab` · string · required — DEPRECATED: use the per-currency `availableToTransfer` of the quote-currency entry in `spotBalances` instead.
  The notional value available to transfer out of the sub-account into the funding account (reported in `settle_currency`).
  `available_balance = total_equity - initial_margin - min(unrealized_pnl, 0)`
- `result.spot_balances` · lite `sb` · object SpotBalance[] · required — The list of spot assets owned by this sub-account, and their balances
- `result.spot_balances[].currency` · lite `c` · string · required — The currency you hold a spot balance in
- `result.spot_balances[].balance` · lite `b` · string · required — This currency's balance in this sub-account.
- `result.spot_balances[].index_price` · lite `ip` · string · required — The index price of this currency. (reported in `USD`)
- `result.spot_balances[].entry_price` · lite `ep` · string · required — The entry price of this spot currency. (reported in `USD`)
- `result.spot_balances[].realized_pnl` · lite `rp` · string · required — The realized PnL of this spot currency. (reported in `USD`)
- `result.spot_balances[].unrealized_pnl` · lite `up` · string · required — The unrealized PnL of this spot currency. (reported in `USD`)
- `result.spot_balances[].available_to_transfer` · lite `at` · string · required — The available to transfer amount of this spot currency.
- `result.spot_balances[].borrowed_amount` · lite `ba` · string · optional — The amount borrowed in this currency, inclusive of accrued interest.
  Only reported by `account_summary`, and only for multi-asset-mode sub-accounts
- `result.positions` · lite `p` · object Positions[] · required — The list of positions owned by this sub-account
- `result.positions[].event_time` · lite `et` · string (int64 unix ns) · required — Time at which the event was emitted in unix nanoseconds
- `result.positions[].sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID that participated in the trade
- `result.positions[].instrument` · lite `i` · string (instrument name) · required — The instrument being represented
- `result.positions[].size` · lite `s` · string · required — The size of the position. Decimal string, e.g. "0.01"; up to the instrument's base_decimals. Negative for short positions
- `result.positions[].notional` · lite `n` · string · required — The notional value of the position, negative for short assets, in the quote asset. Decimal string, e.g. "12.5".
- `result.positions[].entry_price` · lite `ep` · string · required — The entry price of the position. Decimal string, e.g. "65000.5"; up to 9 decimals.
  Whenever increasing the size of a position, the entry price is updated to the new average entry price
  `new_entry_price = (old_entry_price * old_size + trade_price * trade_size) / (old_size + trade_size)`
- `result.positions[].exit_price` · lite `ep1` · string · required — The exit price of the position. Decimal string, e.g. "65000.5"; up to 9 decimals.
  Whenever decreasing the size of a position, the exit price is updated to the new average exit price
  `new_exit_price = (old_exit_price * old_exit_trade_size + trade_price * trade_size) / (old_exit_trade_size + trade_size)`
- `result.positions[].mark_price` · lite `mp` · string · required — The mark price of the position. Decimal string, e.g. "65000.5"; up to 9 decimals.
- `result.positions[].unrealized_pnl` · lite `up` · string · required — The unrealized PnL of the position, in the quote asset. Decimal string, e.g. "12.5".
  `unrealized_pnl = (mark_price - entry_price) * size`
- `result.positions[].realized_pnl` · lite `rp` · string · required — The realized PnL of the position, in the quote asset. Decimal string, e.g. "12.5".
  `realized_pnl = (exit_price - entry_price) * exit_trade_size`
- `result.positions[].total_pnl` · lite `tp` · string · required — The total PnL of the position, in the quote asset. Decimal string, e.g. "12.5".
  `total_pnl = realized_pnl + unrealized_pnl`
- `result.positions[].roi` · lite `r` · string · required — The ROI of the position, expressed as a percentage
  `roi = (total_pnl / (entry_price * abs(size))) * 100^`
- `result.positions[].quote_index_price` · lite `qi` · string · required — The index price of the quote currency. (reported in `USD`)
- `result.positions[].est_liquidation_price` · lite `el` · string · required — The estimated liquidation price
- `result.positions[].leverage` · lite `l` · string · required — The current leverage value for this position
- `result.positions[].cumulative_fee` · lite `cf` · string · required — The cumulative fee paid on the position, in the quote asset. Decimal string, e.g. "12.5".
- `result.positions[].cumulative_realized_funding_payment` · lite `cr` · string · required — The cumulative realized funding payment of the position, in the quote asset. Decimal string, e.g. "12.5". Positive if paid, negative if received
- `result.positions[].margin_type` · lite `mt` · enum PositionMarginType · required — The margin type of the position
  Values: `ISOLATED`, `CROSS` ([details](../enums.md#positionmargintype)).
- `result.positions[].isolated_balance` · lite `ib` · string · optional — [IsolatedOnly] The wallet balance reserved for this isolated margin position, in the quote asset. Decimal string, e.g. "12.5". If this positions is liquidated, this is the maximal balance that can be lost
- `result.positions[].isolated_im` · lite `ii` · string · optional — [IsolatedOnly] The initial margin of the isolated margin position, in the quote asset. Decimal string, e.g. "12.5". The `total_equity` required to open more size in the position
- `result.positions[].isolated_mm` · lite `im` · string · optional — [IsolatedOnly] The maintenance margin of the isolated margin position, in the quote asset. Decimal string, e.g. "12.5". The `total_equity` required to avoid liquidation of the position
- `result.settle_index_price` · lite `si` · string · required — The index price of the settle currency. (reported in `USD`)
- `result.is_vault` · lite `iv` · bool · optional — Whether this sub-account is a vault
- `result.vault_im_additions` · lite `vi` · string · optional — Total amount of IM (reported in `settle_currency`) deducted from the vault due to redemptions nearing the end of their redemption period
- `result.derisk_margin` · lite `dm` · string · required — The derisk margin of this sub-account
- `result.derisk_to_maintenance_margin_ratio` · lite `dt` · string · required — The derisk margin to maintenance margin ratio of this sub-account
- `result.total_cross_equity` · lite `tc` · string · required — The total equity of this sub-account for cross margin
- `result.cross_unrealized_pnl` · lite `cu` · string · required — The unrealized PnL of this sub-account for cross margin
- `result.sub_account_mode` · lite `sa1` · enum SubAccountMode · required — The mode of the sub-account
  Values: `SINGLE_ASSET_MODE` ([details](../enums.md#subaccountmode)).
- `result.margin_balance` · lite `mb` · string · required — The margin balance of this sub-account for cross margin
- `result.algo_trading_enabled` · lite `at` · bool · required — Whether algo trading is enabled for this sub-account

## Errors

Errors come back as `{"code", "message", "status"}` (lite `{"c", "m", "s"}`) with the HTTP status. Codes this call can return, as code, name (HTTP status) ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1003` InvalidRequest (400) · `1006` RateLimit (429, retryable) · `1008` IPNotWhitelisted (401)

## Example

```python
import os

from grvt import Grvt

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
) as client:
    resp = client.sub_account_summary(
        sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
    )
    print(resp)
```

Raw HTTP (set `GRVT_DOMAIN`, see [Environments](../../guides/environments.md); `GRVT_COOKIE` and `GRVT_ACCOUNT_ID` come from [login](../../guides/authentication.md)):

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v1/account_summary" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sub_account_id": "$GRVT_SUB_ACCOUNT_ID"
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v1/account_summary" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sa": "$GRVT_SUB_ACCOUNT_ID"
}
EOF
```
