Trading Dev AcademyFree quant education

Free lesson · Trading different assets

Crypto perpetuals: funding, mark prices and liquidation

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A perpetual is a derivative position that commonly has no scheduled expiry. Funding payments and venue-specific price and collateral rules help connect it to a reference market.

Symbols, units & horizon
  • q: signed underlying units of a linear perpetual, constant during this example
  • P_0,P_1: entry/exit quote prices
  • P_k: contract-defined funding reference price at payment k
  • f_k: signed funding rate for that interval, positive when longs pay
  • C: total quote-currency fees
  • Π: quote-currency profit
  • negative q: short position

When and why to use this

Use a funding-aware ledger when studying perpetual execution, basis or hedged carry.

First determine whether the contract is linear or inverse and which asset serves as collateral and settlement currency. The example here is a linear contract with quantity in underlying units and P&L in quote currency. Inverse contracts require different arithmetic.

Funding transfers value between sides according to the contract’s rate, timing and notional convention. A positive rate often means longs pay shorts, but verify the rule. Rates can change and future funding is not known. Financing a spot hedge adds its own cash and custody costs.

Last trade, reference index and mark price can differ. The venue may use a mark and maintenance-margin schedule for liquidation rather than the price on a simple chart. Cross-margin pools collateral across positions; isolated margin allocates it differently. Neither is a universal loss guarantee.

A cash-and-carry study might combine spot with a short perpetual, but funding, basis changes, hedge mismatch, borrow, exchange risk and forced liquidation remain. Test the full paired ledger under adverse price and funding paths. A high quoted funding rate is an input to investigate, not an annualized return promise.

Π=q(P1−P0)−∑kqPkfk−C
Model assumptions, derivation and arithmetic

Crypto perpetuals: funding, mark prices and liquidation

  1. Compute linear price P&L q(P₁−P₀).
  2. For each funding payment, multiply signed quantity by its reference price and rate. Positive q and positive f create an outflow.
  3. Subtract the funding sum and fees. If positions vary, use the actual signed quantity at each payment instead of one constant q.
Work it by hand

Long .1 units from 50,000 to 50,500 earns 50 quote units. One payment at reference 50,000 with f=.001 costs 5. With fees 4, net is 41. A short with the same positive funding rate receives funding but loses on that price move.

Apply it in a strategy

  • Record linear/inverse payoff, collateral currency, funding schedule and liquidation rules.
  • Reconcile funding and realized/unrealized P&L separately.
  • Stress basis, collateral, venue access and changing funding before assessing carry.

Research deliverable

Show long and short funding signs and explain why a delta hedge does not remove collateral risk.

Funding mechanics & recent research · reviewed 12 September 2026

Coinbase International Exchange’s official funding explanation verifies the positive-rate longs-pay convention for that product family. Other venues and contract wrappers require their own specification. The lesson uses hypothetical rates and does not reproduce a venue’s full margin engine.

Further reading: Coinbase International Exchange · Funding rate ↗

Le’s Funding-Aware Optimal Market Making for Perpetual DEXs is a May 2026 preprint. Abstract and metadata reviewed: it uses Hyperliquid ETH, BTC and SOL funding calibration and holdout simulations, with asset-dependent comparisons against inventory-control baselines. Exact data endpoints, fill proxies and numerical results were not independently checked. Its relevance is the joint inventory/funding exposure; simulated improvement is not evidence of a deployable carry trade.

Further reading: Le · Funding-aware optimal market making · 2026 ↗

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def linear_perp_profit(quantity,entry,exit,funding_prices,funding_rates,fees=0):
    if len(funding_prices)!=len(funding_rates) or fees<0: raise ValueError("Aligned funding records and nonnegative fees required")
    funding=sum(quantity*p*f for p,f in zip(funding_prices,funding_rates))
    return quantity*(exit-entry)-funding-fees,funding

print(linear_perp_profit(.1,50000,50500,[50000],[.001],4))

Continue learning

Trading Different Assets: Instruments, Mechanics & Risk — all lessons
  1. Start with the instrument: exposure, ownership and obligations
  2. Stocks and ETFs: shares, dividends, shorting and fund structure
  3. Bonds and bills: lending, accrued interest and settlement cash
  4. Futures: multipliers, ticks, margin and expiry
  5. Commodities: spot goods, storage and the futures curve
  6. Foreign exchange: two currencies, one quote and financing
  7. Options: rights, premiums, exercise and nonlinear exposure
  8. Spot crypto: tokens, venues, wallets and execution
  9. Crypto perpetuals: funding, mark prices and liquidation
  10. Event contracts: resolution rules and probability-priced exposure

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations