FakeTrade

How the liquidation price is calculated

Published · 4 min read

The liquidation price is the price at which a leveraged position is closed by force, because its losses have used up almost all of its margin. On FakeTrade it is worked out with the formula large exchanges use for an isolated position, from three inputs: the position's size and entry price, the margin it holds, and its leverage bracket.

The examples below use BTC at $80,000, a round price for the arithmetic, and BTC's own bracket table.

The rule

A position is liquidated when its equity — margin plus unrealised P&L — falls to its maintenance margin. For a perp, the maintenance margin is the position value times the bracket's rate, minus a fixed amount that belongs to the bracket:

Maintenance margin = value × rate − amount

Setting the equity equal to the maintenance margin and solving for the price gives the liquidation price of an isolated position:

Long: (size × entry − margin − amount) ÷ (size × (1 − rate))

Short: (size × entry + margin + amount) ÷ (size × (1 + rate))

The bracket is chosen by the position value at the entry price. The margin is what the position actually holds: what you posted, minus any funding it has paid, plus any it has received. At 1× leverage there is no liquidation price at all.

A worked example

Open a long of 0.5 BTC at $80,000 with 10× leverage, isolated:

Value: 0.5 × $80,000 = $40,000

Margin: $40,000 ÷ 10 = $4,000.00

Bracket: up to $200K, rate 0.4%, amount $0.00

Liquidation price: ($40,000 − $4,000.00 − $0.00) ÷ (0.5 × (1 − 0.004)) = $72,289.16

At that price the long has lost $3,855.42, and the $144.58 left is exactly the maintenance margin of a position worth $36,144.58. A liquidation pays no fee, but the margin — $4,000.00 — is lost.

The same position as a short is liquidated at $87,649.40, 9.56% above the entry. The distance is a little smaller on the short side, because the maintenance margin grows as the price rises against a short.

Leverage moves the price closer

Long of 0.5 BTC at $80,000, isolated
LeverageMarginLiquidation priceDistance
10×$4,000.00$72,289.16−9.64%
50×$800.00$78,714.86−1.61%
100×$400.00$79,518.07−0.60%

A rough rule: the distance is a little less than one divided by the leverage, because the maintenance margin has to stay behind. At 100× a move of well under 1% against you ends the position.

Bigger positions sit in other brackets

A long of 4 BTC at $80,000 is worth $320,000, above the first bracket's $200K limit. It falls in the second bracket: rate 0.5%, amount $200.00, maximum 100×. At 20× its margin is $16,000.00, its maintenance margin at the entry $1,400.00 and its liquidation price $76,331.66. An order for it at 150× is refused, because the bracket allows 100×. Leverage brackets explains why the limits fall as positions grow.

What moves the liquidation price later

The server stores the price when the position opens, and figures it again only when something changes the inputs:

  • Adding to the position: a new average entry, more margin and perhaps a new bracket. An add must use the position's own leverage.
  • Closing part of it: a smaller position can fall into a lower bracket, with a lower rate.
  • Funding: on an isolated position every payment changes the margin. After one day of payments on the 10× long above ($12.00 at $80,000), its liquidation price moves from $72,289.16 to $72,313.25. See Funding rate explained.

It does not move with the market. Between those events your liquidation price is a fixed number, and the engine compares every new price with it.

The moment of liquidation

When a new price is at or beyond the liquidation price — at or below it for a long, at or above it for a short — the engine closes the position at that price. An isolated position then loses its whole margin, even if the price that closed it was already past the liquidation price; nothing more is taken from your balance, and no fee is charged. The close appears in your history as a liquidation, with the fees and funding the position had paid counted in its result.

  • It is not a stop-loss. A stop closes the position where you chose and keeps the rest of the margin; a liquidation keeps none of it. An SL above the liquidation price of a long — below it for a short — gets you out first.
  • It is not where the money runs out. At the liquidation price the position still holds its maintenance margin; that last part is lost with the rest.

Cross margin works differently

A cross position has no liquidation price of its own. The engine checks the whole balance instead: when your cash plus the margin and unrealised P&L of all your cross positions falls below their combined maintenance margin, it closes the cross position that is losing most, and checks again. Isolated vs cross margin works through an example.

Check it yourself

The liquidation price calculator uses this formula and the bracket table of every perp on FakeTrade. For a new position its result is the price the server will store. For an isolated position you already hold, enter the funding shown on its position card to see the price as it stands now.

Keep reading

FakeTrade is an educational simulator: no real money, no real trades. Nothing here is financial advice, and the prices in the examples are round numbers chosen for the arithmetic, not forecasts.