> For the complete documentation index, see [llms.txt](https://docs.clickoptions.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clickoptions.ai/trade/index-price.md).

# 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
