Margin and Profit/Loss Calculations

1. Open Position Margin

The opening margin consists of:

  • Initial Margin

  • Opening Loss

Including opening loss in the margin calculation helps prevent immediate liquidation due to unfavorable price movements upon order placement.

1.1 Initial Margin

Initial Margin=Quantity×Contract SizeOrder Price×Leverage\text{Initial Margin} = \frac{\text{Quantity} \times \text{Contract Size}}{\text{Order Price} \times \text{Leverage}}

1.2 Opening Loss

Opening Loss=Quantity×Contract Size×min(0, Order Direction×(1Order Price1Mark Price))\text{Opening Loss} = \text{Quantity} \times \text{Contract Size} \times \left| \min\left(0,\ \text{Order Direction} \times \left( \frac{1}{\text{Order Price}} - \frac{1}{\text{Mark Price}} \right) \right) \right|

Where:

  • Order Direction = 1 for long, -1 for short

Example

  • Contract Type: Coin-margined (e.g., BTC/USD)

  • Order Price: 60,000 USD

  • Mark Price: 55,000 USD

  • Quantity: 12,000 contracts

  • Contract Size: 10 USD

  • Leverage: 10×

Calculation:

Initial Margin:

12,000×1060,000×10=0.2 BTC\frac{12,000 \times 10}{60,000 \times 10} = 0.2\ \text{BTC}

Opening Loss:

12,000×10×min(0,1×(160,000155,000))=0.181819 BTC12,000 \times 10 \times \left| \min\left(0, 1 \times \left( \frac{1}{60,000} - \frac{1}{55,000} \right) \right) \right| = 0.181819\ \text{BTC}

Opening Margin:

0.2+0.181819=0.381819 BTC0.2 + 0.181819 = 0.381819\ \text{BTC}

2. Average Opening Price

When multiple entries are made into the same position, the average opening price is recalculated using a BTC-denominated formula:

Average Opening Price=Total ContractsTotal BTC Value\text{Average Opening Price} = \frac{\text{Total Contracts}}{\text{Total BTC Value}}

Example

  • Position 1: 1,000 contracts @ 5,000 USD

  • Position 2: 2,000 contracts @ 6,000 USD

Total Contracts=1,000+2,000=3,000\text{Total Contracts} = 1,000 + 2,000 = 3,000
Total BTC Value=(1,0005,000)+(2,0006,000)=0.2+0.333333=0.533333 BTC\text{Total BTC Value} = \left( \frac{1,000}{5,000} \right) + \left( \frac{2,000}{6,000} \right) = 0.2 + 0.333333 = 0.533333\ \text{BTC}
Average Opening Price=3,0000.533333=5,625.00 USD\text{Average Opening Price} = \frac{3,000}{0.533333} = 5,625.00\ \text{USD}

3. Profit and Loss Calculation

PnL is calculated based on the difference between inverse prices, since these are reverse (coin-margined) contracts. Profits and losses are settled in the base currency (e.g., BTC), not in USD.

3.1 For Long Positions

Unrealized PnL=Quantity×(1Average Open Price1Mark Price)\text{Unrealized PnL} = \text{Quantity} \times \left( \frac{1}{\text{Average Open Price}} - \frac{1}{\text{Mark Price}} \right)

Example:

  • 1,000 contracts long

  • Average Price: 5,000

  • Mark Price: 5,500

=1,000×(15,00015,500)=0.01819 BTC= 1,000 \times \left( \frac{1}{5,000} - \frac{1}{5,500} \right) = 0.01819\ \text{BTC}

3.2 For Short Positions

Unrealized PnL=Quantity×(1Mark Price1Average Open Price)\text{Unrealized PnL} = \text{Quantity} \times \left( \frac{1}{\text{Mark Price}} - \frac{1}{\text{Average Open Price}} \right)

Example:

  • 1,000 contracts short

  • Average Price: 5,000

  • Mark Price: 4,500

=1,000×(14,50015,000)=0.02223 BTC= 1,000 \times \left( \frac{1}{4,500} - \frac{1}{5,000} \right) = 0.02223\ \text{BTC}

Important Notes

  • Reverse contracts (coin-margined) are settled in the base currency (e.g., BTC).

  • USD values are used only for quotation purposes, not for settlement.

  • This structure ensures that traders earn and lose in the underlying asset they’re trading.

Last updated