Sub topic 9
What happens at liquidation: forced closing, fees and the insurance fund
This chapter follows a position from the moment the exchange flags it until the account is closed. It covers who takes the other side of the forced trade, what fees apply, and how the insurance fund absorbs losses. It assumes you know what margin, maintenance margin, mark price and liquidation price mean from the earlier chapters.
The liquidation trigger
An exchange does not wait for your equity to reach zero. It closes the position when equity falls to the maintenance margin requirement. The check uses the mark price, not the last traded price, so a single odd trade on the order book does not trigger it.
The liquidation price from the earlier chapter is the mark price at which this check first fails:
equity <= maintenance_rate * position_valueThe gap between your initial margin and the maintenance margin is the buffer. The liquidation process exists to close the position while some of that buffer is still left. That remaining equity is what pays for the closing trade.
The sequence of events
Exchanges differ in detail, but most follow the same stages.
- Margin call or warning. Some venues send a notice when margin usage passes a threshold, often 80% to 90% of the maintenance level. Many perpetual futures venues send nothing and move straight to step 2.
- Trigger. The mark price crosses the liquidation price. The engine marks the account as liquidatable.
- Cancel open orders. Resting orders that would raise the account's margin requirement are cancelled. This can free some margin and sometimes lets the account avoid full liquidation.
- Partial liquidation, where supported. Some exchanges close only enough of the position to bring the account back above maintenance with a safety margin. Larger positions are often reduced in tiers.
- Full takeover or market close. If partial closing is not enough, or the exchange does not support it, the engine takes over the whole position.
- Settlement. Any remaining equity after fees is either returned to you or kept by the exchange as a liquidation fee. If equity has gone negative, the shortfall is covered by the insurance fund.
Bankruptcy price versus liquidation price
Two prices matter, and they are easy to confuse.
- The liquidation price is where the engine starts closing the position. At that point you still have equity equal to the maintenance margin.
- The bankruptcy price is where your equity would be exactly zero. For a long position it is lower than the liquidation price. For a short position it is higher.
For an isolated 10x long entered at 100, the initial margin is 10% of position value. The bankruptcy price is therefore about 90. With a 0.5% maintenance rate, the liquidation price is about 90.45, as the earlier code showed. The 0.45 gap is the buffer that pays for closing.
The engine tries to close the position at or better than the bankruptcy price. If it does, the account never goes negative. If the market moves too fast and the fill is worse than bankruptcy, the loss exceeds your margin. That excess is a bad debt the exchange must cover.
Fees at liquidation
Liquidation is more expensive than closing the position yourself. Beyond the normal taker fee, many exchanges charge a separate liquidation fee. It usually comes out of the remaining margin, and some venues route it into the insurance fund.
The following code estimates what a trader gets back, given a closing price and a liquidation fee. It is a simplified model for a long position.
def liquidation_outcome(entry, close_price, size, margin, taker_fee, liq_fee):
"""Settle a forced close of a long position.
size: position size in units of the asset.
margin: collateral posted for this isolated position.
Fees are fractions of the closing position value.
Returns (trader_payout, insurance_fund_change).
"""
pnl = (close_price - entry) * size
close_value = close_price * size
fees = close_value * (taker_fee + liq_fee)
equity = margin + pnl - fees
if equity >= 0:
# Remaining equity goes back to the trader, minus the liq fee,
# which in this model is already included in fees.
return equity, close_value * liq_fee
# Negative equity is bad debt, paid from the insurance fund.
return 0.0, equity
# 10x long, 1 unit at 100, margin 10.
# Closed near the liquidation price of 90.45:
print(liquidation_outcome(100.0, 90.45, 1, 10.0, 0.0005, 0.005))
# Closed in a fast market at 88, below the bankruptcy price of 90:
print(liquidation_outcome(100.0, 88.0, 1, 10.0, 0.0005, 0.005))In the first case the trader keeps a small positive amount and the fund gains the liquidation fee. In the second case the fill is worse than bankruptcy, the trader receives nothing, and the fund pays the negative amount returned as the second value.
How the position is actually closed
There are three common mechanisms.
| Mechanism | How it works | Main risk |
|---|---|---|
| Market order into the book | The engine sends a forced sell (for a long) or buy (for a short) to the order book. | Slippage in thin books can push the fill past bankruptcy. |
| Liquidation vault or backstop | A designated pool or market-making vault takes over the position at a set price and unwinds it later. | The vault can lose money if the market keeps moving. |
| Insurance fund takeover | The fund takes the position and closes it over time. | Fund losses if the market keeps moving against the position. |
Market-order liquidation is the simplest, and it is also the mechanism that feeds liquidation cascades. Each forced sell lands on the same order book as everyone else's orders and moves the price. The cascade chapter covers that feedback loop.
The insurance fund
The insurance fund is a pool of assets held by the exchange to cover bad debt from liquidations. It is funded mainly by the surplus from liquidations that close better than bankruptcy, plus part of the liquidation fees.
Think of it as a shared cushion with a one-way flow in normal times.
- Liquidations that close above bankruptcy for a long, or below it for a short, add the difference.
- Liquidations that close at a worse price subtract the shortfall.
- In calm markets the fund grows. In violent markets it can shrink quickly.
The fund protects the winning side. Without it, the exchange would have to take profit away from the traders on the other side of the trade to cover the shortfall. The fund's size relative to open interest is a useful health indicator. A fund of a few hundred million dollars sounds large, but it can be small next to tens of billions in open interest.
When the fund is not enough
If bad debt exceeds the fund, the exchange has two options: socialize the loss or use auto-deleveraging. Socializing spreads the loss across all profitable traders as a haircut. Auto-deleveraging instead forcibly closes the positions of the most profitable, most leveraged traders on the opposite side, at the bankruptcy price of the failed position. The next chapter covers it in detail. For now, note that the insurance fund is the first line of defense and auto-deleveraging is the last.
Common errors and misconceptions
- Believing you lose only the margin shown. In an isolated position you normally lose at most the margin, because the engine closes you first. In cross margin, the whole account balance backs the position, so you can lose much more than the single position's margin.
- Assuming you get filled at the liquidation price. The liquidation price is where the process starts. The actual fill can be better or worse, depending on the order book and the engine's method.
- Ignoring the liquidation fee. A position that survives to 0.5% above liquidation has a smaller usable buffer than the chart suggests, because the fee comes out of what is left.
- Confusing mark price and last price. A wick on the last price may not touch your liquidation if the mark price does not move with it. The reverse also holds: the mark price can cross your level while the last price looks calm.
- Assuming partial liquidation always happens. Some venues liquidate the entire position at once. Check the documentation for the specific exchange.
- Treating the insurance fund as a guarantee. It is a finite pool. When it runs dry, other traders pay.
Reading an exchange's liquidation rules
Before you trade on a venue, look for these points in its documentation.
- Is liquidation partial or full?
- What is the liquidation fee, and does it go to the insurance fund?
- What is the maintenance margin rate at your position size? Tiers raise it for larger positions.
- Which price index feeds the mark price?
- What happens when the insurance fund is empty: socialized loss or auto-deleveraging?
Exercise
A trader opens a 10x isolated long of 2 units at an entry price of 100, so the margin is 20. The position is force-closed at 89, which is below the bankruptcy price of 90. Ignoring fees, how much does the trader receive, and how much does the insurance fund pay?
Show answer
The loss is (100 - 89) * 2 = 22. The margin is 20, so equity is 20 - 22 = -2. The trader receives 0, and the insurance fund pays the 2 units of bad debt.
Exercise
Why does an exchange liquidate a position at the maintenance margin level instead of waiting until equity reaches zero?
Show answer
Closing a position costs money through slippage and fees. Liquidating while some equity remains (the buffer between maintenance margin and zero) lets that equity pay for the closing trade. This makes it more likely that the account does not go negative and that the insurance fund is not needed.
Exercise
The insurance fund balance falls sharply during a rapid price drop. What does this tell you about how the liquidations closed?
Show answer
Many liquidations closed at prices worse than their bankruptcy prices. The fund paid the resulting shortfalls, which means the market moved faster or the order book was thinner than the engine could handle.