Sub topic 11
Index Price and Mark Price
This chapter assumes you know how order books and spot markets work, what a perpetual swap is, and the basics of margin. You should also be able to read short Python functions. Perpetual swaps have no expiry, so their price has to be tied to spot some other way. Two reference prices do that job: the index price and the mark price. This chapter explains how each one is built, what each one is used for, and the errors that come from mixing them up.
Three prices on one screen
A perpetual swap screen shows several prices at once.
| Price | Where it comes from | What it is used for |
|---|---|---|
| Last price | The most recent trade on the venue's own perpetual order book | Display, charts, and fills of your own orders |
| Index price | A weighted average of spot prices across several exchanges | The spot reference for the perpetual |
| Mark price | The index price plus a smoothed adjustment for the perpetual's premium | Unrealized PnL, margin checks, and liquidation |
Your orders still fill at the order book price. The mark price decides how your open position is valued and when it is liquidated.
The index price
The index price is an estimate of the "true" spot price of the underlying asset. A venue builds it from the spot prices of several large exchanges. It does not use its own order book alone. Using many sources makes the number hard to move. A trader who pushes the price on one exchange only shifts that exchange's contribution to the average.
Typical construction rules:
- Each source contributes its mid price or last price, often the mid of the best bid and ask.
- Each source has a weight. Weights may be fixed, or based on trading volume or liquidity.
- A source that goes stale, stops responding, or deviates too far from the others is dropped or down-weighted.
- Some venues use a median instead of a mean, so a single bad feed cannot move the result much.
The sketch below shows a weighted index with a deviation filter. Real venues differ in the details, but the structure is the same.
from statistics import median
def index_price(quotes, weights, max_deviation=0.02):
"""quotes: {exchange: price}; weights: {exchange: weight}.
Drops any source more than max_deviation away from the median,
then returns the weighted average of the sources that remain.
"""
mid = median(quotes.values())
kept = {
name: price
for name, price in quotes.items()
if abs(price / mid - 1) <= max_deviation
}
total_weight = sum(weights[name] for name in kept)
return sum(price * weights[name] for name, price in kept.items()) / total_weight
quotes = {"A": 60010.0, "B": 59990.0, "C": 60005.0, "D": 52000.0}
weights = {"A": 0.4, "B": 0.3, "C": 0.2, "D": 0.1}
print(index_price(quotes, weights))Exchange D reports a price about 13% below the median. The filter drops it, so the index stays near 60,000 instead of being dragged down.
The mark price
The mark price is the venue's fair value for the perpetual contract. It is not the last traded price. The perpetual's own order book can be thin or briefly distorted. If liquidations were triggered by the last price, one large order or a single odd trade could wipe out many positions.
A common construction is:
mark = index × (1 + smoothed premium)
The premium is how far the perpetual trades above or below the index. The smoothing can be a moving average of the premium over a short window, or a median of several price sources. Another common form is:
mark = index + moving average of (mid price of the perpetual − index)
where the mid price is the average of the best bid and best ask. Because the adjustment is smoothed, a brief spike on the perpetual's order book changes the mark price only slightly.
Some venues also clamp the result. The mark price may not stray beyond a fixed percentage band around the index, which gives a hard limit on how far a distorted order book can pull it.
def mark_price(index, perp_mid_history, clamp=0.05):
"""index: current index price.
perp_mid_history: recent (perp_mid - index) differences, oldest first.
"""
basis = sum(perp_mid_history) / len(perp_mid_history)
raw = index + basis
low, high = index * (1 - clamp), index * (1 + clamp)
return min(max(raw, low), high)
history = [20.0, 25.0, 30.0, 400.0, 28.0]
print(mark_price(60000.0, history))The single outlier of 400 raises the average, but only to 100.6, so the mark price rises by far less than the spike itself. A shorter window or a median would limit the outlier's effect further.
Which price is used where
The split of duties is the main thing to remember.
| Use | Reference price | Reason |
|---|---|---|
| Order matching | Perpetual order book | You trade against real resting orders |
| Unrealized PnL shown in the margin check | Mark price | It resists manipulation |
| Liquidation trigger | Mark price | Avoids liquidations caused by brief spikes |
| Funding rate premium | Index price compared with the perpetual price | Funding pulls the perpetual toward spot |
| Realized PnL on close | Your actual fill price | The trade happened at that price |
On many venues the funding payment itself is calculated on position notional at the mark price. The next chapter covers funding in detail.
The diagram shows how the prices relate.
A worked example
Suppose BTC's index price is 60,000 and you hold a long position of 1 BTC, opened at 60,000, with 10x isolated margin. A thin order book briefly pushes the last price of the perpetual down to 54,500 for a few seconds, then it recovers.
- With a last-price rule, your unrealized loss would read as 5,500, which is more than your 6,000 of margin allows once maintenance margin is counted. The position could be liquidated by a momentary glitch.
- With a mark-price rule, the index stays near 60,000. The smoothed premium moves only a little, so the mark price might dip to about 59,900. Your position is nowhere near liquidation.
The long-side liquidation estimate from the earlier formula, for 10x leverage and 0.5% maintenance margin, is about 54,271 for entry at 60,000. The mark price, not the last price, has to reach that level.
def liquidation_price(entry, leverage, maintenance_margin_rate, side):
"""Isolated-margin linear contract, ignoring fees and funding."""
if side == "long":
return entry * (1 - 1 / leverage) / (1 - maintenance_margin_rate)
return entry * (1 + 1 / leverage) / (1 + maintenance_margin_rate)
def is_liquidated(mark, entry, leverage, mmr, side):
liq = liquidation_price(entry, leverage, mmr, side)
return mark <= liq if side == "long" else mark >= liq
print(is_liquidated(54500, 60000, 10, 0.005, "long"))
print(is_liquidated(59900, 60000, 10, 0.005, "long"))The first call uses the spike price as if it were the mark price and returns True. The second uses the realistic mark price and returns False.
Common errors and edge cases
- Reading the last price as the liquidation reference. Your chart may touch a level without your position being liquidated, or the reverse. Always check which price the venue uses for liquidation.
- Assuming all venues build the index the same way. Source lists, weights, and filters differ. The same asset can have slightly different index prices on two venues.
- Forgetting that the index can be wrong. If several sources fail at once, or a thinly traded token has few spot markets, the index is easier to move. Low-liquidity contracts carry more index risk.
- Mark price far from last price during stress. In a fast crash, the last price on the perpetual can trade well below the mark. Resting orders fill at the lower price, but liquidation still follows the mark. Slippage on closing can then exceed what you expect.
- Inverse contracts. The mark price still drives margin and liquidation, but because margin is held in the base coin, a falling price also reduces the dollar value of your collateral.
- Different prices for different products. A dated future often has its own mark price rule. It may be based on the index plus a fair basis computed from time to expiry. Do not assume the perpetual's rule carries over.
Summary
The index price is a spot reference built from several exchanges. The mark price is the venue's fair value for the perpetual, built from the index plus a smoothed premium. Margin checks, unrealized PnL, and liquidation use the mark price, while your actual fills use the order book. This separation protects traders from short-lived price distortions and sets up the funding mechanism covered next.
Exercise
A perpetual's index price is 3,000. Its recent premium readings (perpetual mid minus index) are 4, 6, 5, 5, and 80 (a brief spike). Using the simple average of the readings as the smoothed premium with no clamp, what is the mark price? Then explain why the venue prefers it over the last price of 3,080 for liquidation checks.
Show answer
The average premium is (4 + 6 + 5 + 5 + 80) / 5 = 20, so the mark price is 3,000 + 20 = 3,020. The spike moved the mark by 20 instead of 80. Using the mark price means a short-lived distortion on the perpetual's own order book does not trigger liquidations. A median of the readings (5) would have limited the spike even more.
Exercise
A long position is opened at 60,000 with 10x isolated leverage and a 0.5% maintenance margin rate. The venue's last price falls to 54,000 for one second while the mark price stays at 59,000. Is the position liquidated? Use the liquidation formula from this chapter.
Show answer
The liquidation price is 60,000 × (1 − 0.1) / (1 − 0.005) ≈ 54,271. Liquidation depends on the mark price, which is 59,000 and above 54,271, so the position is not liquidated. The last price of 54,000 is below the threshold but is not the liquidation reference.