Sub topic 10
Perpetual swaps
This chapter assumes you know how dated futures work (expiry, settlement, basis), what margin and leverage mean, and how to read short Python functions. It covers what a perpetual swap is, how it differs from a dated future, and the errors people commonly make with it. Index price, mark price, and funding get their own chapters, so they appear here only as pointers.
What a perpetual swap is
A perpetual swap (often "perp") is a derivative contract that tracks the price of an asset and never expires. A trader opens a long or short position, holds it as long as margin allows, and closes it by trading the opposite side.
A dated future is pulled toward spot by expiry. At expiry the contract settles at the spot index, so futures and spot must meet. A perp has no expiry, so that anchor does not exist. Perps use a periodic payment between longs and shorts, called the funding rate, to push the contract price toward spot.
Perpetual swaps were popularized in crypto by BitMEX in 2016. They are now the most heavily traded crypto derivative on most venues, usually by a wide margin over dated futures.
The word "swap" comes from traditional finance. The contract behaves like a continuous series of short-term swaps in which the two sides exchange the price return of the asset for a funding payment.
Comparison with spot and dated futures
| Property | Spot | Dated future | Perpetual swap |
|---|---|---|---|
| You own the asset | Yes | No | No |
| Expiry | None | Fixed date | None |
| Leverage | No (unless borrowed) | Yes | Yes |
| Anchor to spot | Is the spot price | Convergence at expiry | Funding payments |
| Recurring cost or income | None | Basis embedded in price | Funding every interval |
| Rolling needed | No | Yes, before expiry | No |
The last row matters in practice. A trader who wants to hold a futures exposure for six months must sell the expiring contract and buy the next one. Each roll pays the bid-ask spread and fees twice, and the roll price depends on the basis at that moment. A perp avoids this, but it replaces the roll cost with funding, which can be positive or negative and changes from one interval to the next.
The core mechanism
Three pieces work together.
- The contract price. This is the last traded price or the order book mid price on the venue. It reflects supply and demand for the perp itself.
- The index price. This is a weighted average of spot prices from several exchanges. It stands in for the "true" price of the asset.
- The funding rate. This is a payment exchanged between longs and shorts at fixed intervals, commonly every eight hours, though some venues use one hour or four hours.
When the perp trades above the index, longs are more eager than shorts. The funding rate turns positive and longs pay shorts. That makes holding a long more expensive and holding a short more attractive, which pushes the perp price down toward the index. When the perp trades below the index, the sign flips.
Funding is a transfer between traders. The venue does not collect it. This is different from trading fees, which go to the venue.
Funding payments in code
The payment equals position notional times the funding rate. Notional is quantity times the mark price. The sign depends on side.
def funding_payment(qty, mark_price, funding_rate, side):
"""Positive result means the trader pays; negative means the trader receives."""
notional = qty * mark_price
payment = notional * funding_rate
return payment if side == "long" else -payment
print(funding_payment(1.0, 60000, 0.0001, "long"))
print(funding_payment(1.0, 60000, 0.0001, "short"))The long pays 6.0 and the short receives 6.0. A rate of 0.0001 (0.01%) per eight hours looks small, but there are three intervals a day. Over a year that is 0.0001 × 3 × 365 = 0.1095, or about 11% of notional. With 10x leverage, that is about 110% of the margin posted.
Settlement and P&L
A perp's profit and loss depends on the contract type. A linear perp is quoted and settled in a stablecoin such as USDT, so profit is quantity times price change. An inverse perp is margined and settled in the base coin, so profit depends on the difference of reciprocal prices.
def linear_pnl(qty, entry, exit_price, side):
sign = 1 if side == "long" else -1
return sign * qty * (exit_price - entry)
def inverse_pnl_btc(contracts_usd, entry, exit_price, side):
sign = 1 if side == "long" else -1
return sign * contracts_usd * (1 / entry - 1 / exit_price)
print(linear_pnl(0.5, 60000, 66000, "long"))
print(inverse_pnl_btc(10000, 60000, 66000, "long"))The linear long earns 3000 USDT. The inverse long earns about 0.01515 BTC, which is worth about 1000 USD at the exit price. Inverse profit in USD terms is smaller on the way up and the loss is larger on the way down, because the margin itself is a coin whose value moves with the price. This is the convexity of inverse contracts.
Perps also have no delivery. Closing a position realizes the P&L in the settlement currency. Venues also settle unrealized P&L into the account balance continuously or at funding times, depending on the design.
Common errors
- Treating funding as a fee to the venue. It is paid between traders. A venue earns from trading fees and liquidation fees.
- Ignoring funding in a long hold. A long position that is right on price can still lose money if funding stays positive for weeks. Compute funding as an annualized cost before holding.
- Assuming the perp equals spot. The perp can trade above or below the index, especially in fast markets. The funding rate corrects the gap gradually, not instantly.
- Paying funding on a position you closed. Funding is charged only if you hold the position at the funding timestamp. Closing one second before avoids the payment, and opening one second after avoids it too. Some traders time entries around this, but spread and fees usually outweigh the saving.
- Confusing the funding rate shown with the rate you will pay. Many venues display a predicted rate for the next interval. The final rate is set at the timestamp and can differ.
- Mixing contract types. A "BTCUSD" inverse contract and a "BTCUSDT" linear contract on the same venue have different margin currencies and different P&L formulas.
Edge cases
Negative funding. In falling or fearful markets the perp trades below the index, and shorts pay longs. Holding a short then costs money. Funding is symmetric by design.
Different intervals. One venue may charge 0.01% every eight hours and another 0.0025% every hour. The daily total is similar for those two examples, but you should always convert to a common unit, such as an annualized percentage, before comparing.
Funding and liquidation. Funding payments reduce the margin balance. A position close to its liquidation price can be pushed over the line by a funding payment alone, with no price move.
No convergence guarantee. A dated future must equal spot at expiry, so its basis is bounded in time. A perp has no such bound. Its premium can stay wide while funding is high, because arbitrageurs may be limited by capital, borrowing costs, or venue risk.
Who uses perps
- Directional traders use perps for leveraged exposure without rolling.
- Hedgers short perps against spot holdings to cut price risk while keeping the coins.
- Funding-rate harvesters hold spot long and a perp short of equal size. When funding is positive, the short side receives it, and the price risks offset. The basis trade chapter covers this in full.
Summary of the working model
A perp is a futures-style contract with no expiry. The mark and index prices determine P&L and liquidation, and the funding rate ties the contract to spot. Your real cost of holding a position is funding plus fees plus slippage, and that cost can change sign.
Exercise
A trader holds a long perp position of 2 BTC with a mark price of 50,000 USDT at the funding time. The funding rate is 0.0003. (a) How much does the trader pay or receive? (b) If the rate stayed the same for three intervals a day, what is the annualized cost as a percentage of notional?
Show answer
(a) Notional = 2 × 50,000 = 100,000 USDT. Payment = 100,000 × 0.0003 = 30 USDT, and the trader pays because the rate is positive and the position is long. (b) 0.0003 × 3 × 365 = 0.3285, or 32.85% of notional per year.
Exercise
Why can a perpetual swap price stay above spot for weeks, while a dated future cannot stay above spot at expiry?
Show answer
A dated future settles at the spot index on its expiry date, so its price must converge to spot by then. A perp has no expiry, so nothing forces convergence on a fixed date. Only funding pushes it toward spot, and it works through incentives. If arbitrageurs lack capital or the funding rate is not high enough to attract them, the premium can persist.