GetPositions
Get all open positions for your account, including size, entry price, mark price, unrealized PnL, and leverage.
GET
GetPositions🔐 Auth RequiredReturns all open perpetual positions for your account. Includes real-time mark price and unrealized PnL calculations.
Request
| Parameter | Type |
|---|---|
market_idoptional | uint32 |
Response
| Field | Type |
|---|---|
success | bool |
positions | Position[] |
timestamp | uint64 |
Example
Requesttypescript
const positions = await client.getPositions();for (const pos of positions) {console.log(`${pos.market} ${pos.side.toUpperCase()}`);console.log(` Size: ${pos.size}`);console.log(` Entry: ${pos.entryPrice}`);console.log(` Mark: ${pos.markPrice}`);console.log(` PnL: ${pos.unrealizedPnl}`);console.log(` Leverage: ${pos.leverage}x`);}// Check specific marketconst rlmPosition = positions.find(p => p.market === 'RLM-PERP');
Responsejson
{"success": true,"positions": [{"market": "RLM-PERP","marketId": 0,"side": "long","size": 10.0,"entryPrice": 95.50,"markPrice": 100.25,"unrealizedPnl": 47.50,"realizedPnl": 0.0,"leverage": 5.0,"margin": 191.0,"liquidationPrice": 76.40,"openedAt": 1704067200000000000}],"timestamp": 1704067200000000000}
Position Structure
| Field | Type | Description |
|---|---|---|
market | string | Market symbol (e.g., RLM-PERP) |
market_id | uint32 | Market ID |
side | string | "long" or "short" |
size | int64 | Position size (8 decimals) |
entry_price | int64 | Average entry price (8 decimals) |
mark_price | int64 | Current mark price (8 decimals) |
unrealized_pnl | int64 | Unrealized profit/loss (8 decimals) |
realized_pnl | int64 | Realized profit/loss (8 decimals) |
leverage | int64 | Effective leverage (8 decimals) |
margin | int64 | Margin allocated to position (8 decimals) |
liquidation_price | int64 | Price at which position is liquidated (8 decimals) |
opened_at | uint64 | Position open timestamp (nanoseconds) |
PnL Calculation
Unrealized PnL is calculated as:
- Long:
(markPrice - entryPrice) × size - Short:
(entryPrice - markPrice) × size
Real-time Updates
For real-time position updates, use the Subscribe endpoint with positions: true. You'll receive updates on:
- Position opens (new fills)
- Position size changes (partial fills)
- Position closes
- Mark price updates (affects PnL)
- Funding payments