Skip to main content
In our trading system, per-position metrics are derived from position value and quantity. Entry price, unrealized PnL, notional value, margin requirements, and liquidation price all update in real time as the index price changes.

Key Definitions

TermDescription
positionQtySigned position size — positive for long, negative for short
positionValueSigned cost basis of the position
indexPriceCurrent market index price
leverageLeverage applied to the position
MMRMaintenance margin rate — fixed at 0.1 (10%)
side+1 for long positions, -1 for short positions

Average Entry Price & Notional Value

FieldFormulaDescription
avgEntryPricepositionValue / positionQtyWeighted average fill price for the position
positionNotionalValueindexPrice × positionQtySigned current market value of the position

Unrealized PnL

Unrealized PnL reflects the current profit or loss on an open position, based on the index price relative to the average entry price.
unrealizedPnL = (indexPrice - avgEntryPrice) × positionQty
Because positionQty is signed, this formula naturally handles both directions:
  • Long (positionQty > 0): profit when indexPrice > avgEntryPrice
  • Short (positionQty < 0): profit when indexPrice < avgEntryPrice

Position Margin & Maintenance Margin

Position margin is the collateral locked to support an open position. Maintenance margin is the minimum collateral required to keep the position open.
FieldFormulaDescription
positionMarginindexPrice × ABS(positionQty) / leverageCollateral locked for the position at the current index price
maintenanceMarginindexPrice × ABS(positionQty) × MMRMinimum collateral required to keep the position open
The maintenance margin rate (MMR) is fixed at 10%. A position is at risk of liquidation when account equity falls below the sum of all maintenance margins across open positions.

Liquidation Price

The liquidation price is the index price at which a position will be forcibly closed due to insufficient margin. Rails uses a cross-margin model, so margin availability is computed across all open positions.
marginAvailable = accountEquity - SUM(maintenanceMargin)

liqPrice = indexPrice - (side × marginAvailable) / (ABS(positionQty) × (1 - side × MMR))
marginAvailable is the equity cushion remaining after covering all maintenance margins. It differs from availableBalance (see Account Equity & Balances), which is based on position margin and open order margin.

Usage in API

These calculations are used in the Get Account Positions and Get Account Balances responses. Note that several formula variable names differ from their corresponding response field names:
Formula variableResponse fieldEndpoint
positionValuevalueGet Account Positions
positionQtyquantityGet Account Positions
unrealizedPnLunrealizedPnlGet Account Positions
positionNotionalValuenotionalValueGet Account Positions
liqPriceliquidationPriceGet Account Positions
positionMarginmarginGet Account Balances
avgEntryPrice is not returned directly — derive it from value / quantity in the positions response.