# Mark Price

### **Overview**

To improve the **stability** of the contract market and **reduce unnecessary forced liquidations** during periods of high volatility, the system uses a **marked price** rather than the last traded price. The marked price is used to:

* Calculate a user's **unrealized profit and loss (PnL)**
* Trigger **forced position reductions** (liquidations) when necessary

### **Marked Price Formula**

$$
\text{Marked Price} = \text{Median} \left( P\_{\text{latest}},\ P\_{\text{reasonable}},\ P\_{\text{ma}} \right)
$$

Where:

* P<sub>latest</sub>: Latest transaction-related price
* P<sub>reasonable</sub>: Reasonable theoretical price
* P<sub>ma</sub>: Moving average adjusted price

### **Components Breakdown**

#### 1. **Latest Price** P<sub>latest</sub>

This is the **median** of three values:

$$
P\_{\text{latest}} = \text{Median} \left( P\_{\text{buy1}},\ P\_{\text{sell1}},\ P\_{\text{trade}} \right)
$$

Where:

* P<sub>buy1</sub>: Best bid (Buy 1)
* P<sub>sell1</sub>​: Best ask (Sell 1)
* P<sub>trade</sub>​: Last transaction price

#### 2. **Reasonable Price** P<sub>reasonable</sub>

Calculated as:

$$
P\_{\text{reasonable}} = P\_{\text{index}} \times \left( 1 + F\_{\text{prev}} \times \frac{t\_{\text{remain}}}{T} \right)
$$

Where:

* P<sub>index</sub>: Spot market index price
* F<sub>prev</sub>​: Funding rate of the **previous period**
* t<sub>remain</sub>​: Time remaining until the next funding fee settlement
* T: Funding fee settlement interval (e.g., 480 minutes for 8-hour cycles)

#### 3. **Moving Average Price** P<sub>ma</sub>​

$$
P\_{\text{ma}} = P\_{\text{index}} + \text{MA}\_5(\Delta)
$$

Where:

* MA<sub>5</sub>(Δ): 5-minute moving average of the **spread**
* Spread Δ(n) is defined as:

$$
\Delta(n) = P\_{\text{exchange}}(n) - P\_{\text{index}}(n)
$$

And:

* P<sub>exchange</sub>(n): Exchange’s median price at time nnn
* P<sub>index</sub>: Index price at time nnn

### **Summary**

The **marked price** integrates:

* Short-term trading dynamics
* Fair value via funding-adjusted index pricing
* Smoothing through moving averages

This hybrid pricing mechanism enhances risk control and protects users from unfair liquidations during momentary price spikes or dips.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coinlocally.com/perpetual-contracts/overview/mark-price.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
