# Index and Mark Price

## Index Price

The **Index Price** represents the real-time price of the underlying asset derived from aggregated spot market prices. Astros calculates this price every second by combining market data from multiple exchanges alongside the **Pyth Network oracle**.

#### Aggregation Sources:

* Exchanges: **Coinbase**, **Binance**, **OKX**
* Oracle Protocol: **Pyth Network**

{% hint style="info" %}
**Note:** For BTC-denominated trading pairs, the price is converted to USD using the OKX BTC-USD index.
{% endhint %}

#### Index Price Validation and Adjustment:

To maintain price accuracy and stability, Astros applies two safeguards:

* **Exchange Data Validity:**\
  Prices from exchanges that have outdated trade data (no recent trades or insufficient trading volume within a predefined period) are excluded from calculations.
* **Price Deviation Adjustment:**\
  If an exchange's reported price deviates by more than **±3%** from the median price of all exchanges, the outlier price is adjusted as follows:

$$
\text{Adjusted Exchange Price} =
\begin{cases}
\text{Median Price} \times 1.03 & \text{(if Exchange Price > Median by 3%)} \[6pt]
\text{Median Price} \times 0.97 & \text{(if Exchange Price < Median by 3%)}
\end{cases}
$$

***

### Mark Price

Astros adopts a **Mark Price** mechanism (Fair Price Marking) to mitigate liquidation risk due to temporary market manipulation, volatility, or illiquidity.

#### Calculation Formula:

$$
\text{Mark Price} = \text{Index Price} + \text{30-Minute Moving Average (Premium)}
$$

Where the **30-Minute Moving Average (Premium)** is computed as:

$$
\text{30-Minute Moving Average} = \text{Moving Average}\left\[ \frac{(\text{Bid Price} + \text{Ask Price})}{2} - \text{Index Price} \right]
$$

This moving average is continuously sampled every second over a rolling 30-minute window.

***

### Unrealized Profit and Loss (PnL) Clarification

After executing a trade, traders may observe positive or negative unrealized profits and losses (PnL) caused by temporary differences between the executed trade price and the Mark Price.

* **Important**: Unrealized PnL fluctuations do **not** represent actual realized gains or losses unless the position is closed or liquidated.
* It is crucial to monitor your **liquidation price** closely to avoid unintended liquidation due to short-term price discrepancies.
