# Price Architecture

Pricing an asset is subtly complex. VDEX measures the price of perpetuals through robust price indices and displays cosmetic values for client-side monitoring. &#x20;

#### Robust Price Indices

VDEX utilizes various price types to minimize the risk of market manipulation.

*pOracle:* the oracle price is an external data feed used in calculating the funding rate and in *pMark.* The data source depends on the asset class.

* Crypto - Binance, updates every second
* Stocks, Commodities, and Foreign Exchange - TwelveData, updates every five seconds
* Prediction Markets - Seda, updates every 200ms

*pMark:* the mark price is designed to be a fair approximation of the perp price. It is used in calculating unrealized PnL and margin requirements, as well as for TP/SL and liquidation triggers. *pMark* updates every second and is the median value of:

* *pOracle* plus a 150 second exponential moving average (EMA) of the difference between *pMid* and *pOracle*
* The median of the best bid, best ask, and *pLast* on VDEX
* *pOracle*

*pImpact*: the impact price measures market depth at *pMid*. Bid and ask orders of size *$1,000* are simulated against the order book. The median of the average execution prices is *pImpact. pImpact* is used exclusively in calculating the funding rate.

*pMid*: the mid price is the average price between the best bid price and best ask price. *pMid* is used in calculating *pMark*.

*pLast*: the last price is the most recent price at which an order was executed. *pLast* is used in calculating *pMark,* appears in the token dashboard, and appears on trading charts.

#### Display Prices

The protocol's fundamental state is based solely on margin. The following prices are inferred from margin and displayed for convenient monitoring:

* Entry price is updated to the average of the former entry price and successive trade prices, weighted by size
* Exit price is the executed price of an order.
* Expected price is the simulated execution price based on position size and the current state of the order book
* Unrealized PnL is the difference between entry price and *pMark*, scaled by position size
* Realized PnL measures the absolute change in margin from a position. It excludes funding payments and fees.
* Liquidation price reflects the point at which account equity falls below the maintenance margin requirement

#### Formulas

<details>

<summary>Exponential Moving Average</summary>

The exponential moving average (EMA) is calculated using the following method. Let `sample` be the new data point, and let `t` be the time (in minutes) since the last update.

The EMA is defined as:

`ema = numerator_new / denominator_new`

`numerator_new -> numerator_prev * exp(-t / 2.5) + sample * t`

`denominator_new -> denominator_prev * exp(-t / 2.5) + t`

This formulation applies a **decay factor over a 2.5-minute window**, giving more weight to recent values while smoothing out short-term noise.

</details>


---

# 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.vdex.trade/trading/vdexcore/price-architecture.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.
