The leverage you are trading with depends on your available balance. Bitfex uses the entirety of a trader's account balance as margin to avoid any liquidations.
With market movements, Net Asset Value (NAV) and margins will fluctuate.
Initial Margin and Maintenance Margin
Initial Margin(IM) is the minimum account balance required to initiate a position.
IM = Order Value (in BTC) * IM Percentage
IM Percentage = IM%
Maintenance Margin(MM) is the minimum account balance required to keep a position open.
MM = Position Value (in BTC) * MM Percentage
MM Percentage = MM%
Initial Margin and Maintenance margin will be calculated for every order and trades.
Initial Margin will be blocked for all open positions and open orders (except the orders that will reduce the position size).
Profit and Loss
Profit and Loss is calculated on the basis of entry and exit/market prices. There are two types of profit/loss (PnL), realised and unrealised.
Entering and exiting positions on Bitfex happens as per the 'First-In, First-Out' (FIFO) principle, with PnL and average entry price calculations reflecting the same. FIFO implies that contracts in positions entered first are also the contracts that are sold/bought first when a position is being exit.
This includes profits and/or losses from closed positions, trading fees and funding fees.
This is PnL for open positions. Unrealised PnL is calculated on the basis of mark price. Unrealised PnL can be negative or positive immediately after an order executes. This happens when the mark price is different from the last price. Do note, unrealised profits are always added in real time to the NAV.
Suppose you enter a long position (buy) of 1000 contracts in BTCUSD at $6000 You enter another long position of 1000 contracts in BTCUSD at $5000 and another long position of 1000 contracts when BTCUSD price is $7000 Now, Total Position (in BTC) = 1000/6000 + 1000/5000 + 1000/7000 = 0.50952381 BTC Total Contracts = 1000 + 1000 + 1000 = 3000 Average Entry Price = Total Contracts/ Total Position (in BTC) = 3000/0.50952381 = $5887.85 Now suppose, after some days the Mark Price for BTCUSD is $9050 You unrealised PnL will be calculated as follows Unrealised PnL = [1/Entry Price for 1st position - 1/ Mark Price]* Contracts in Position 1 + [1/Entry Price for 2nd position - 1/ Mark Price]* Contracts in Position 2 + [1/Entry Price for 3rd position - 1/ Mark Price]* Contracts in Position 3 = [1/6000 - 1/9050] * 1000 + [1/5000 - 1/9050] * 1000 + [1/7000 - 1/9050] * 1000 = 0.53409629 BTC Now, suppose you exit at $9000 by selling half your total position, i.e. 1500 contracts, then as per FIFO, the contracts in the position that was taken first will be exit first, followed by contracts in the second position and so on. Hence, your Realised PnL will be calculated as follows Realised PnL = [1/Entry Price for 1st position - 1/ Exit Price]* Sold Contracts in Position 1 + [1/Entry Price for 2nd position - 1/ Mark Price]* Sold Contracts in Position 2 = [1/6000 - 1/9000] * 1000 + [1/5000 - 1/9000] * 500 = 0.1 BTC
Average Entry Price
The average entry price for a position is given by the total number of contracts in the position divided by the value (in BTC) of the total position entered.
Suppose you place 2 buy orders, Order 1- 10,000 BTCUSD buy at $9,900 and Order 2- 20,000 BTCUSD buy at $10,100 Total Position (in BTC) = 10,000/9,900 + 20,000/10,100 = 2.99029903 BTC Total Contracts = 10,000 + 20,000 = 30,000 Average Entry Price = Total Contracts/ Total Position (in BTC) = 30,000/2.99029903 = $10032.44 If you decide to exit half your position, i.e. 15,000 contracts when BTCUSD is at $12000, then as per FIFO, your average entry price will be calculated as follows Now, Total Position (in BTC) = 0/9,900 + 15,000/10,100 = 1.48514851 BTC Total Contracts = 15,000 Average Entry Price (after exiting) = Total Contracts/ Total Position (in BTC) = 15,000/1.48514851 = $10100
NAV and Account Balance
There are two types of account balance, NAV (Net Asset Value) and Available Balance.
NAV will be used for Liquidation Process and Available Balance will be used to check order placement.
Available Balance = NAV – IM Blocked
For example, a user deposit 1 BTC to his account.
NAV = 1 BTC
Available Balance = 1 BTC
Say the trader places an order of value 2 BTC, then for IM% = 5% IM = 5% of 2 BTC = 0.1 BTC Say fees charged is 0.075%, then Fee = 0.075% of 2 BTC = 0.00150 BTC
Updated NAV = 1 - Fee = 1-0.00150 = 0.99850 BTC Available Balance = 0.99850 - 0.1 = 0.899850 BTC
While placing a new order, if IM > Available Balance, order will be rejected.
As soon as NAV<=IM, a margin call will be issued to the trader via email. The trader can then choose to keep their positions open by increasing their account balance, and/or cancelling some or all open orders and/or closing some or all positions.
Liquidation happens when NAV becomes less than or equal to the Maintenance Margin.
As soon as NAV<=MM, the Bitfex Liquidation Engine takes over the trader's position, all the open orders are cancelled, and liquidation orders are sent to market. During the liquidation event, a trader has no control over their account and cannot place, cancel or modify any orders from their account.
This will continue till NAV > MM.
A liquidation fee of 0.6% is charged, that goes to the insurance fund.
During liquidation, if NAV becomes less than zero, it is known as bankruptcy. In the case of a bankruptcy, the Bitfex insurance fund cover's the bankrupted account's losses.