# Positions and liability


Source: https://docs.stxapp.io/concepts/positions/

STX does not simply debit the cost of an order when you place it and credit the payout when
the market settles. It tracks several liability categories that change in real time as
orders are placed, matched and settled.

---

## Wallet Fields

| Field | Description |
|-------|-------------|
| `available_balance` | Cash you can use to place new orders |
| `buy_order_liability` | Risk tied up in unfilled buy orders |
| `sell_order_liability` | Risk tied up in unfilled sell orders |
| `position_premium_liability` | Risk from contracts you currently hold |

Your total exposure at any moment is the sum of all liability fields. The `available_balance`
decreases when you place an order and can increase as orders are filled.

Subscribe to the [`balances`](/websockets/channels/balances/) channel to receive live updates
whenever any of these numbers change.

---

## Order Liability

When you place an order the exchange immediately reserves the maximum possible loss; this is
your **order liability**.

- **Buy order**: `price × quantity`. A limit buy of 10 contracts at $0.45 incurs $4.50 of
  order liability, reducing `available_balance` by the same.
- **Sell order**: `(max_price − price) × quantity`. A limit sell of 10 contracts at $0.36 on a
  market with `max_price` `"1.0000"` incurs `(1.00 − 0.36) × 10` = $6.40 of order liability.

---

## Position Liability

When a trade executes on your order, order liability converts to **position liability**, the
maximum loss on the contracts you now hold.

Importantly, this conversion often **increases your available balance**, because you filled at
a better price than your limit. For example:

- You place a limit buy for 10 contracts at $0.45 → order liability $4.50, and
  `available_balance` drops by the same.
- Five fill at $0.43 → position liability for those 5 is $2.15, and order liability
  for the 5 still resting is $2.25. Total $4.40.
- `available_balance` therefore rises by $0.10: $0.02 saved on each of the 5 contracts
  that filled below your limit.

---

## Closing a Position

Placing an order on the opposite side of an existing position does not add new liability;
it hedges the existing one.

**Example:** You hold a long position of 10 contracts bought at $0.45 ($4.50 of
position liability). You place a sell order for 5 contracts at $0.60.

- The sell order does not change your available balance, because your total risk is unchanged.
- When the sell fills, a settlement is generated: `5 × (0.60 − 0.45)` = **$0.75 gross
  profit**, added to available balance.
- Position liability drops to $2.25 (5 remaining contracts × $0.45).
- Your maximum possible loss is now `2.25 − 0.75` = **$1.50** net, because you have locked in
  $0.75 of profit regardless of the final result.

---

## Settlement at Expiry

When a market resolves, open contracts settle at the market's `max_price` or at $0. A `push`
or `settled` result pays out between the two; see
[One market is one outcome](/concepts/market-shape/#one-market-is-one-outcome).

- **Won**: position liability is released and you receive `max_price × quantity`. Net gain is
  `(max_price − avg_price) × quantity`.
- **Lost**: contracts settle at $0. The position liability is released, but you receive
  nothing back; your maximum loss on the position was already reserved.

All transactions are fully capitalized. There is no margin or leverage.

---

## Monitoring Positions in Real Time

| Channel | What it delivers |
|---------|-----------------|
| [`balances`](/websockets/channels/balances/) | Available balance and liability totals |
| [`positions`](/websockets/channels/positions/) | Per-market position summary, including unrealized P&L |
| [`fills`](/websockets/channels/fills/) | Individual trade confirmations |
| [`settlements`](/websockets/channels/settlements/) | Settlement records as they are created |
