Perpetual contracts are a cornerstone of the crypto trading landscape, offering significant opportunity alongside considerable risk. A deep understanding of the core calculations governing margin, profit and loss, and liquidation is essential for effective risk management. This guide breaks down the fundamental formulas and concepts in a clear, structured manner.
Core Concepts and Definitions
Before diving into calculations, let's establish a common vocabulary for key terms used in perpetual contract trading.
- Account Equity: The total value of your contract account. It is calculated as:
Account Equity = Initial Margin + Realized P&L + Unrealized P&L. - Available Margin: The portion of your equity available to open new positions or withstand losses. Formula:
Available Margin = Account Equity - (Position Size / (Mark Price * Leverage)) - Order Margin. - Mark Price: The price used to calculate unrealized P&L and avoid liquidation caused by market manipulation. It is derived from the
Spot Index Price + Moving Average of Basis. - Maintenance Margin Rate: The minimum margin ratio required to maintain an open position. If your margin ratio falls to or below this rate plus the taker fee rate, your position will be liquidated.
Calculating Profit and Loss
Accurately calculating your gains and losses is critical. These calculations differ for long and short positions and are split into realized and unrealized P&L.
Unrealized P&L (Floating P&L)
This represents the profit or loss on your currently open positions, calculated since the last daily settlement.
- Long Position:
Unrealized P&L = (Contract Value / Entry Price) - (Contract Value / Mark Price) - Short Position:
Unrealized P&L = (Contract Value / Mark Price) - (Contract Value / Entry Price)
Realized P&L
This is the profit or loss from positions that have been fully or partially closed since the last settlement. This value is net of trading fees.
- Long Position (Closing):
Realized P&L = (Contract Value / Entry Price - Contract Value / Exit Price) * Number of Contracts - Short Position (Closing):
Realized P&L = (Contract Value / Exit Price - Contract Value / Entry Price) * Number of Contracts
For a more precise breakdown of how these values impact your available capital in real-time, you can often 👉 view real-time calculation tools on major trading platforms.
Margin and Leverage Explained
Leverage amplifies both gains and losses. Understanding how margin is calculated in different modes is paramount.
Cross Margin vs. Isolated Margin
- Cross Margin: All available balance in your contract account is used as collateral for all open positions. Your
Initial Marginfluctuates with the mark price. - Isolated Margin: Margin is allocated and fixed to a specific position. Your
Initial Marginis calculated at entry and remains fixed, isolating the risk to that specific position's collateral.
Initial Margin Calculation
The amount required to open a position depends on the mode.
- Initial Margin (Cross) = (Contract Value Number of Contracts) / (Mark Price Leverage)
- Initial Margin (Isolated) = (Contract Value Number of Contracts) / (Entry Price Leverage)
The Initial Margin Rate is simply the inverse of your leverage: 1 / Leverage.
Liquidation and Bankruptcy Prices
Liquidation occurs when your margin is insufficient to maintain your position. The price at which this happens is the liquidation price.
Estimating Liquidation Price
- Isolated Long:
Liquidation Price ≈ Entry Price / (1 + Maintenance Margin Rate) - Isolated Short:
Liquidation Price ≈ Entry Price / (1 - Maintenance Margin Rate)
Cross-margin calculations are more complex as they involve your entire account equity. If the mark price hits your estimated liquidation price, the system's liquidation engine will take over.
Bankruptcy Price and Insurance Fund
Positions are closed at the bankruptcy price, not the liquidation price.
- If the closing price is better than bankruptcy, the surplus is added to the platform's insurance fund.
- If a "socialized loss" occurs (i.e., the position closes at a worse price than bankruptcy), the loss is first covered by the insurance fund. Any remaining loss is then socialized among all profitable traders on the platform that day.
Funding Fees Mechanism
Perpetual contracts use funding fees to tether the contract price to the spot index price. Fees are exchanged between long and short traders every 8 hours.
- Funding Fee = Position Value * Funding Rate
- The
Funding Rateis calculated periodically based on the premium of the contract price over the spot index price. It is clamped within a set boundary (e.g., -0.3% to +0.3%). - A positive rate means longs pay shorts. A negative rate means shorts pay longs.
- You only pay or receive funding if you hold a position at the exact time of the funding fee snapshot.
Daily Settlement Process
A daily settlement occurs to realize profits and losses and collect funding fees.
- P&L Settlement: All unrealized P&L is converted into realized P&L. The settlement price becomes the new benchmark for calculating future unrealized P&L.
- Funding Fee Exchange: The funding fee is calculated and transferred between long and short positions, affecting account balances.
- Socialization Check: The system checks for any insolvent losses not covered by the insurance fund and initiates the socialization process among profitable traders if necessary.
Frequently Asked Questions
What is the difference between mark price and last price?
The last price is the most recent transaction price. The mark price is a calculated value based on the spot index and premium, used to determine liquidation and unrealized P&L to prevent unnecessary liquidations due to volatile or illiquid markets.
How can I avoid liquidation?
You can avoid liquidation by maintaining a healthy margin level. Use lower leverage, monitor your margin ratio closely, add more margin to your position (in isolated mode), or close a portion of your position to free up collateral.
What happens if I can't be liquidated at the bankruptcy price?
If a liquidated position cannot be closed at or above the bankruptcy price, the resulting loss is called a "socialized loss." This loss is first covered by the platform's insurance fund. If the fund is insufficient, the remaining loss is distributed among all traders who were net profitable that day.
When are funding fees paid?
Funding fees are typically exchanged every 8 hours. The exact times can vary by exchange but are often at 00:00, 08:00, and 16:00 UTC. You only pay or receive the fee if you have an open position at the time of the funding snapshot.
Is isolated margin safer than cross margin?
Isolated margin is often considered safer for risk management because it limits your maximum loss to the specific margin you allocated to that trade. Cross margin uses your entire account balance, which can protect you from liquidation on one position but potentially puts your entire account at risk.
Why did my position close before hitting my stop-loss?
This is almost always due to liquidation. Your margin ratio, calculated using the mark price, fell to the maintenance level before your stop-loss price (based on the last price) was reached. Always calculate your liquidation price based on the mark price, not the last traded price. To explore advanced risk management strategies for volatile markets, you can 👉 explore more hedging strategies.