Sub topic 2
Basis and convergence
This chapter assumes you know what spot prices are, how an exchange order book works, and how to read simple Python.
Basis and convergence
The basis is the gap between a dated future's price and the spot price: basis = futures − spot. When futures trade above spot, the market is in contango. When they trade below spot, it is in backwardation. A dated future settles at the spot price on its expiry date, so the basis shrinks toward zero as expiry approaches. This process is convergence.
def basis(spot, futures):
return futures - spot
def annualized_basis(spot, futures, days_to_expiry):
return (futures / spot - 1) * 365 / days_to_expiry
print(basis(60000, 61500))
print(round(annualized_basis(60000, 61500, 90) * 100, 2))Linear and inverse contracts
A linear contract settles in the quote currency, such as USDT. A long position's profit is quantity × (exit − entry). An inverse contract is margined in the base coin, so its profit depends on reciprocal prices.
def linear_pnl(qty, entry, exit_price):
return qty * (exit_price - entry)
def inverse_pnl_btc(contracts_usd, entry, exit_price):
return contracts_usd * (1 / entry - 1 / exit_price)
print(linear_pnl(0.5, 60000, 66000)) # 3000.0 USDT
print(inverse_pnl_btc(10000, 60000, 66000)) # about 0.01515 BTCMargin and leverage
Leverage multiplies exposure relative to the margin you post. At 10x, margin is one tenth of the position's notional value. Isolated margin caps the loss at the margin of one position. Cross margin shares the account balance across all positions.
Perpetual swaps
A perpetual swap is a future with no expiry date. Convergence at a fixed date does not happen here. Instead, periodic funding payments between longs and shorts pull the swap price toward the index.
Index price and mark price
The index price is a weighted average of spot prices from several exchanges. The mark price drives unrealized profit and liquidation checks. It blends the index with the swap's own order book price, which limits the damage from a brief manipulated trade.
Exercise
A dated future trades at 61500 and spot is 60000, with 90 days to expiry. Is the market in contango or backwardation, and does the basis grow or shrink as expiry nears?
Show answer
The market is in contango because the future trades above spot. The basis shrinks toward zero as expiry nears, through convergence.