# Margin

Cross-margin is used by default. That is, a trader's collateral is shared across all open positions, and gains from one position can offset losses from another.

A trader's portfolio value is calculated as collateral + total realized and unrealized pnl from trades. Leverage for the entire portfolio is calculated as total notional value / portfolio value. This means that by specifiying a size for the new trade, a new leverage for the portfolio is determined, and vice versa.

If a trader has $n$ open positions, where the signed size for each position $i$ is $q_i$, index price is $p_i$, and initial margin requirement ratio is $r_{\text{init},i}$, the total initial margin requirement is calculated as $\sum_{i=1}^n |q_i|p_ir_{\text{init},i}$. A trader can open a new position as long as the portfolio value is at least the total initial margin requirement. Otherwise, the trade will not be executed.

Maintenance margin requirement is defined similarly but with maintenance margin requirement ratio $r_{\text{maintenance},i}$, and if the portfolio value becomes less than the maintenace margin requirement (due to total unreazlied pnl being significantly negative), the account will undergo partial or full liquidations.

Last updated