# Price feed

### Composite index weighting

Perpetual swaps track an underlying composite index, which is a weighted average price of spot prices across a selection of exchange offerings. Exactly which exchanges to use is a parameter that can be be modified from an initial setting via governance.&#x20;

While it is fairly trivial to add more exchanges with custom weightings (which can become necessary as the exchange supports numerous assets), at the moment, the DerivaDEX composite index price is currently constructed in the following manner:

#### Price feed input sources

| Exchange | Weighting |
| -------- | --------- |
| Binance  | 33.33%    |
| Gemini   | 33.33%    |
| Coinbase | 33.33%    |

### Update criterion

The DerivaDEX price feed updates every second, if and only if the price has changed by more than `1 bps` (0.01%). This is similar to the standards of highly performany centralized exchanges.

### Price feed attributes

The price feed emits "Price checkpoint" events that are stored in the system's verifiable state, that contain the following information:

#### Index price

The index price is the weighted average composite price as per the details above.

#### EMA

The EMA (exponential moving average) tracks the spread between the DerivaDEX perpetual swap's price and the underlying index price it is tracking. It is derived in the following manner:

1. Compute the `fair_price` of the DerivaDEX order book, which is the midpoint of the best available bid and ask. `fair_price = avg(best_bid, best_ask)`.
2. Compute the `premium`, which is the difference between the `fair_price` and the composite index price. `premium = fair_price - index_price`.
3. Compute the latest `ema` value of this `premium` using a 30-period EMA multiplier and the last computed `ema`. `ema = (premium - previous_ema) * (2/31) + previous_ema`.

In the case where the DerivaDEX order book is consistently trading above the composite index price, this `ema` will be positive, and if it is trading below the index price, it will be negative. This `ema` field has special significance for computing and distributing [funding rate](/trading/perpetual-swap/funding-rate.md)-related payments.

if there is an empty order book, the `fair price` is set equal to the `index price`.

### Mark price

The mark price is used to assess liquidations and depict unrealized PNLs for positions. It can be calculated using the `index_price` and `ema` described above: `mark_price = index_price + delta` where delta is the `ema` bounded to 0.5% of the index price.


---

# 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.derivadex.io/platform-features/price-feed.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.
