---
title: "Positions"
description: "List a sub-account's open positions."
---

| | |
|---|---|
| SDK | `client.positions(...)` |
| HTTP | `POST https://trades.<domain>/full/v1/positions`, or `/lite/v1/positions` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v1/positions` 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 | `position.positions` (`RPCPositionsV1`) |

## Request

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

- `sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID to request for
- `kind` · lite `k` · enum Kind[] · optional, default `all` — The kind filter to apply. If nil, this defaults to all kinds. Otherwise, only entries matching the filter will be returned
  Values: `PERPETUAL`, `FUTURE`, `CALL`, `PUT`, `SPOT_SWAP`, `STABLE_PERP` ([details](../enums.md#kind)).
- `base` · lite `b` · string[] · optional, default `all` — The base filter to apply. If nil, this defaults to all bases. Otherwise, only entries matching the filter will be returned
- `quote` · lite `q` · string[] · optional, default `all` — The quote filter to apply. If nil, this defaults to all quotes. Otherwise, only entries matching the filter will be returned

## Response

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

- `result` · lite `r` · object Positions[] · required — The positions matching the request filter
- `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 that participated in the trade
- `result[].instrument` · lite `i` · string (instrument name) · required — The instrument being represented
- `result[].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[].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[].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[].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[].mark_price` · lite `mp` · string · required — The mark price of the position. Decimal string, e.g. "65000.5"; up to 9 decimals.
- `result[].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[].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[].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[].roi` · lite `r` · string · required — The ROI of the position, expressed as a percentage
  `roi = (total_pnl / (entry_price * abs(size))) * 100^`
- `result[].quote_index_price` · lite `qi` · string · required — The index price of the quote currency. (reported in `USD`)
- `result[].est_liquidation_price` · lite `el` · string · required — The estimated liquidation price
- `result[].leverage` · lite `l` · string · required — The current leverage value for this position
- `result[].cumulative_fee` · lite `cf` · string · required — The cumulative fee paid on the position, in the quote asset. Decimal string, e.g. "12.5".
- `result[].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[].margin_type` · lite `mt` · enum PositionMarginType · required — The margin type of the position
  Values: `ISOLATED`, `CROSS` ([details](../enums.md#positionmargintype)).
- `result[].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[].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[].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

## 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) · `3007` NotApplicableForSpotInstrument (400)

## 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.positions(
        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/positions" \
  -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/positions" \
  -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
```
