# Ⅱ. Mark price and Last price

OKX

1. What is mark price and last price of margins and contracts?

Mark price is a reference price applied to calculate unrealized profit and loss of users, as a tool to reduce unnecessary forced liquidation in an abnormal volatile market and improve the stability of contracts market.

Last price refers to the latest traded price of the orderbook for a margin or contract. It is determined by the most recent trade filled for that margin or contract. Although the contracts derive their value from their underlying asset, their prices don't necessarily reflect the spot price of that asset.

2. How to calculate mark price of Futures and Perpetuals?

2.1 Calculate the mark price of Futures and Perpetual

Mark price = Index price + Basis of moving average

Basis of moving average

= Moving average of (Mid price of contract - Index price)

= Moving average of [(Best ask of contract + Best bid of contract) / 2 - Index price]

Note: USDT-margined, USDC-margined and crypto-margined contracts refer to the index price of base currency as their index price.

E.g. BTCUSDT perpetual contract refers to the BTC/USDT index price, BTCUSDC perpetual contract refers to the BTC/USDC index price, BTCUSD perpetual contract refers to the BTC/USD index price.

The mark price takes into account both the spot index price and the moving average of the basis. The moving average mechanism reduces the fluctuations in the short-term contract price and reduces unnecessary forced liquidation caused by abnormal volatility.

2.2 Calculate the mark price of Margin

USDT and Crypto margin pairs:

Refer to the index price of base currency as their index price;

Mark price = Index price + Basis of moving average

Basis of moving average

= Moving average of (Mid price of spot - Index price)

= Moving average of [(Best ask of spot + Best bid of spot) / 2 - Index price]

Note: USDT margin, USDC margin and crypto margin pairs refer to the index price of base currency as their index price.

E.g. BTC/USDT margin pair refers to the BTC/USDT index price, BTC/USDC margin pair refers to the BTC/USDC index price, ETH/BTC margin pair refers to the ETH/BTC index price.

Mark price takes the index price and the basis of moving average into account. Moving average mechanism filters contract price fluctuations over a short period and minimizes abnormal situations that could lead to unnecessary forced liquidation.

3. Use cases

Calculate the floating profit and loss of contracts using mark price and last price:

A)Using Mark price

1. Crypto-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (1 / Average entry price - 1 / Average mark price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (1 / Average mark price - 1 / Average entry price)

1. USDT-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (Average mark price - Average entry price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (Average entry price - Average mark price)

1. USDC-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (Average mark price - Average entry price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (Average entry price - Average mark price)

B) Using Last price

1. Crypto-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (1 / Average entry price - 1 / Last price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (1 / Last price - 1 / Average entry price)

1. USDT-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (Last price - Average entry price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (Average entry price - Last price)

1. USDC-margined contract

PnL of long positions = Contract size × |Number of contracts| × Multiplier × (Last price - Average entry price)

PnL of short positions = Contract size × |Number of contracts| × Multiplier × (Average entry price - Last price)

By considering both mark price and last price in the calculation of floating profit and loss, users can have a more comprehensive understanding of their positions' performance. Mark price helps in reducing unnecessary liquidations due to abnormal market volatility, while last price reflects the most recent trading activity for the margin or contract.

Calculate the floating profit and loss of margin:

Please refer to this document for the floating PnL formulas: https://www.okx.com/support/hc/en-us/articles/6997022292493