GetPositions

Get all open positions for your account, including size, entry price, mark price, unrealized PnL, and leverage.

GETGetPositions🔐 Auth Required

Returns all open perpetual positions for your account. Includes real-time mark price and unrealized PnL calculations.

Request

ParameterType
market_idoptionaluint32

Response

FieldType
successbool
positionsPosition[]
timestampuint64

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 market
const 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

FieldTypeDescription
marketstringMarket symbol (e.g., RLM-PERP)
market_iduint32Market ID
sidestring"long" or "short"
sizeint64Position size (8 decimals)
entry_priceint64Average entry price (8 decimals)
mark_priceint64Current mark price (8 decimals)
unrealized_pnlint64Unrealized profit/loss (8 decimals)
realized_pnlint64Realized profit/loss (8 decimals)
leverageint64Effective leverage (8 decimals)
marginint64Margin allocated to position (8 decimals)
liquidation_priceint64Price at which position is liquidated (8 decimals)
opened_atuint64Position 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