WebSocket API

Positions Channel

Authenticated position updates for your account

Channel name: position

Authentication

You must send a successful auth message before subscribing.

{ "op": "sub", "channel": "position" }

No params field is required. The stream is account-scoped.

Message Types

Snapshot

Sent immediately after subscribing. Contains a position object for every enabled market, including markets where the user has no open position (net_sz: "0").

{
  "channel": "position",
  "type": "snapshot",
  "data": [
    {
      "mkt_idx": 1,
      "mkt_id": "BTC-PERP",
      "net_sz": "1.5",
      "avg_entry_px": "50000.00",
      "quote_bal": "-75000.00",
      "mark_px": "50100.00",
      "idx_px": "50095.00",
      "mrgn_mode": "MARGIN_MODE_CROSS",
      "lev": "10",
      "mrgn_bal": "7500.00",
      "init_mrgn_req": "5000.00",
      "maint_mrgn_req": "2500.00",
      "liq_px": "45100.00",
      "unrlzd_pnl": "150.00",
      "tot_fund_paid": "5.00",
      "iso_usdc_bal": "0",
      "free_iso_usdc_bal": "0",
      "in_iso_liq": false,
      "mrgn_ratio": "0.033"
    }
  ],
  "gsn": 12345,
  "ts": "1234567890000000000"
}

Update

Incremental position changes from trade fills. The data field is a single position object (not an array). The filter field identifies which market was updated.

{
  "channel": "position",
  "type": "update",
  "filter": "BTC-PERP",
  "data": {
    "mkt_idx": 1,
    "mkt_id": "BTC-PERP",
    "net_sz": "2.0",
    "avg_entry_px": "50025.00",
    "quote_bal": "-100050.00",
    "mark_px": "50150.00",
    "idx_px": "50145.00",
    "mrgn_mode": "MARGIN_MODE_CROSS",
    "lev": "10",
    "mrgn_bal": "10000.00",
    "init_mrgn_req": "10005.00",
    "maint_mrgn_req": "5002.50",
    "liq_px": "45022.50",
    "unrlzd_pnl": "250.00",
    "tot_fund_paid": "5.00",
    "iso_usdc_bal": "0",
    "free_iso_usdc_bal": "0",
    "in_iso_liq": false,
    "mrgn_ratio": "0.033"
  },
  "gsn": 12346,
  "ts": "1234567891000000000"
}

Fields

Position fields in WebSocket messages use the same v1Position schema as the REST API:

FieldTypeDescription
filterstringMarket ID (update messages only, e.g. "BTC-PERP")
mkt_idxnumberMarket signing index
mkt_idstringMarket ID
net_szstringNet size (positive = long, negative = short)
avg_entry_pxstringAverage entry price
quote_balstringQuote balance
mark_pxstringCurrent mark price
idx_pxstringCurrent index price
mrgn_modestringMARGIN_MODE_CROSS or MARGIN_MODE_ISOLATED
levstringLeverage
mrgn_balstringMargin balance
init_mrgn_reqstringInitial margin requirement
maint_mrgn_reqstringMaintenance margin requirement
liq_pxstringLiquidation price
unrlzd_pnlstringUnrealized PnL
tot_fund_paidstringCumulative funding payments
iso_usdc_balstringIsolated USDC balance
free_iso_usdc_balstringFree isolated USDC balance
in_iso_liqbooleanIn isolated liquidation
mrgn_ratiostringMargin ratio

See the full schema in GET /portfolio and GET /positions/history.

On this page