# Index price

The **Options Index Price** is our proprietary benchmark for valuing and settling option contracts. It is designed to be **robust against manipulation**, **resistant to stale data**, and **consistent across multiple exchanges**.

#### Calculation Flow

1. **Validation of Inputs**
   * Underlying asset, timestamp, and list of quotes must be present.
   * If any are missing, the index cannot be derived.
2. **Filter Non-Stale Quotes**
   * Only quotes marked as *fresh* are considered.
   * If no fresh quotes remain → index calculation fails.
3. **Extract Candidate Prices**
   * For each valid quote, the **midOrLast() price** is taken.
   * These values form the **candidate price set**.
4. **Median Aggregation**

   * The index is the **median** of candidate prices:

   $$
   IndexPrice =
   \begin{cases}
   Price\_{\frac{n+1}{2}}, & n \text{ is odd} \\\[10pt]
   \frac{Price\_{\frac{n}{2}} + Price\_{\frac{n}{2}+1}}{2}, & n \text{ is even}
   \end{cases}
   $$

   * Median ensures stability and reduces sensitivity to outliers.
5. **Final Scaling**
   * Result is rounded to the configured **scale** (precision) using *half-up rounding*.
6. **Result Packaging**
   * Final index object contains:
     * Underlying asset ID
     * Timestamp (epoch ms)
     * Calculated index price
     * Contributing quotes (exchange + price)

#### Example (Odd Number of Quotes)

**Input Quotes (Fresh Only):**

* Exchange A: 100,000
* Exchange B: 100,050
* Exchange C: 99,950
* Exchange D: 100,200
* Exchange E: 99,900

**Step 1 – Sorted Candidate Prices:**

\[99,900,  99,950,  100,000,  100,050,  100,200]\[99,900,\\; 99,950,\\; 100,000,\\; 100,050,\\; 100,200]\[99,900,99,950,100,000,100,050,100,200]

**Step 2 – Median:**

* n=5n = 5n=5 (odd)
* Median = 3rd value = **100,000**

**Final Index Price:**

IndexPrice=100,000.00IndexPrice = 100{,}000.00IndexPrice=100,000.00


---

# 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.clickoptions.ai/trade/index-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.
