Margin Balance and PnL Calculation
2023/09/04 11:59:06
Under the USDⓈ-M perpetual Futures, each user has an independent Derivatives Account, which is used for the collateral and settlement of derivatives transaction funds.
Margin Balance
The margin balance is the real-time assets of the Derivatives Account, that is, the total assets of the Derivatives Account, including unrealized profit and loss (PnL). Margin balance is divided into cross margin balance and isolated margin balance.
Cross Margin Balance = Account Balance - All Position Cost of Isolated Margin + All Unrealized PnL of Cross Margin
Isolated Margin Balance = Position Cost of Isolated Margin + Isolated Unrealized PnL
When the margin balance ≤ the maintenance margin, a forced deleveraging or liquidation will be triggered.
Account Balance Calculation
Account Balance = Total Net Transferred-In Assets + Realized PnL - Total Trading Fee - Total Liquidation Fee + Total Funding Fee - Amount from Options Orders + Options PnL
Formula Details:
Account Balance = (Transfer-In + Transfer-Out) + (Realized PnL of Cross and Isolated Positions) - (Total Opening and Closing Fee of Cross Position + Total Opening and Closing Fee of Isolated Position) - Liquidation Fee of Cross and Isolated Positions + Funding Fee of Cross and Isolated Positions - (Options Equity + Options Fee) + Options PnL
Available Balance Calculation in Cross Margin Mode
The available balance in the cross margin mode is the margin that can be used to open a position in the cross margin mode. The unrealized PnL of the cross position can be used to continue to open the position.
1. Single-Currency Margin & Hedge Mode
Available Balance = account balance of pricing currency in the current trading zone - isolated position cost of all symbols in the current trading zone - cross position cost of all symbols in the current trading area - frozen margin of all symbols in the current trading zone + unrealized PnL of all symbols in the current trading zone
and,
Single Position Cost = Position Quantity * Entry Price / Leverage
Frozen Margin of a Single Order = Order Quantity * Order Price / Leverage
Unrealized PnL of a Single Position:
Long = (Latest Mark Price - Entry Price) * Position Quantity
Short = (Entry Price - Latest Mark Price) * Position Quantity
2. Single-Currency Margin & One-Way Mode
(1) When the buy & sell direction is the same as the position direction, the available balance is calculated as follows:
Available Balance = account balance of pricing currency in the current trading zone - isolated position cost of all symbols in the current trading zone - cross position cost of all symbols in the current trading area - frozen margin of all symbols in the current trading zone + unrealized PnL of all symbols in the current trading zone
and,
Single Position Cost = Position Quantity * Entry Price / Leverage
Frozen Margin of a Single Order = Order Quantity * Order Price / Leverage
Unrealized PnL of a Single Position:
Long = (Latest Mark Price - Entry Price) * Position Quantity
Short = (Entry Price - Latest Mark Price) * Position Quantity
(2) When the buy & sell direction is opposite to the position direction, the available balance is calculated as follows:
Available balance = account balance of the pricing currency in the current trading zone - isolated position cost of all symbols in the current trading zone - cross position cost of other symbols in the current trading zone - frozen margin of all symbols in the current trading zone + unrealized PnL of all symbols in the current trading zone + cross position cost of the current symbol
3. Multi-Currency Margin & Hedge Mode
Available Balance = USD value of all currencies in all trading zones - isolated position cost of all symbols in USD value in all trading zones - cross position cost of all symbols in USD value in all trading zones - frozen margin of all symbols in USD value in all trading zones + unrealized PnL of the cross position of all symbols in USD value in all trading zones
4. Multi-Currency Margin & One-Way Mode
(1) When the buy & sell direction is the same as the position direction, the available balance is calculated as follows:
Available Balance = USD value of all currencies in all trading zones - isolated position cost of all symbols in USD value in all trading zones - cross position cost of all symbols in USD value in all trading zones - frozen margin of all symbols in USD value in all trading zones + unrealized PnL of the cross position of all symbols in USD value in all trading zones
(2) When the buy & sell direction is opposite to the position direction, the available balance is calculated as follows:
Available Balance = USD value of all currencies in all trading zones - isolated position cost of all symbols in USD value in all trading zones - cross position cost of other symbols in USD value in all trading zones - frozen margin of all symbols in USD value in all trading zones + unrealized PnL of the cross position of all symbols in USD value in all trading zones + cross position cost of the current symbol in the current trading zone
Available Balance Calculation in Isolated Margin
The isolated margin does not support the multi-currency mode.
1. Single-Currency Margin & Hedge Mode
Available Balance = account balance of pricing currency in the current trading zone - isolated position cost of all symbols in the current trading zone - cross position cost of all symbols in the current trading area - frozen margin of cross position of all symbols in the current trading zone
2. Single-Currency Margin & One-Way Mode
(1) When the buy & sell direction is the same as the position direction, the available balance is calculated as follows:
Available Balance = account balance of pricing currency in the current trading zone - isolated position cost of all symbols in the current trading zone - cross position cost of all symbols in the current trading area - frozen margin of the cross position of all symbols in the current trading zone
(2) When the buy & sell direction is opposite to the position direction, the available balance is calculated as follows:
Available balance = account balance of the pricing currency in the current trading zone - isolated position cost of other symbols in the current trading zone - cross position cost of all symbols in the current trading zone - frozen margin of all symbols in the current trading zone + isolated position cost of the current symbol
Unrealized PnL
Long = (Latest Mark Price - Entry Price) * Position Quantity
Short = (Entry Price - Latest Mark Price) * Position Quantity
E.g. A user opened a Long BTCUSDT position under the hedge mode with 0.2 BTC long at the price of 28,000 USDT, and then he opened a Short BTCUSDT position with 0.1 BTC at the price of 28,500 USDT. When the latest mark price reaches 29,000 USDT, the unrealized PnL of the position is:
Long: ( 29000 - 28000 ) * 0.2 = 200 USDT
Short: ( 28500 - 29000 ) * 0.1 = - 50 USDT
Realized PnL
Long = (Closing Price - Entry Price) * Closing Quantity
Short = (Entry Price - Closing Price) * Closing Quantity
Let’s continue from the previous example, as the market keeps going up, the user closes these two positions at a price of 29,500 USDT. The realized PnL of the position is:
Long: ( 29500 - 28000 ) * 0.2 = 300 USDT
Short: ( 28500 - 29500 ) * 0.1 = - 100 USDT