# Volatility index

## SQL API

### `public_data.volatility_index`

Minute-resolution OHLC bars of the volatility index published by an exchange. Currently the primary source is **Deribit's DVOL** for `BTC` and `ETH` — a 30-day forward-looking implied-volatility index analogous to the VIX in traditional finance.

#### Columns

| Column      | Type                   | Description                                   |
| ----------- | ---------------------- | --------------------------------------------- |
| `exchange`  | LowCardinality(String) | Exchange that publishes the index (`deribit`) |
| `market`    | LowCardinality(String) | Underlying asset (`BTC`, `ETH`)               |
| `timestamp` | DateTime64(9, 'UTC')   | Bar timestamp                                 |
| `open`      | Decimal(76, 20)        | Open value of the index for the bar           |
| `high`      | Decimal(76, 20)        | High value                                    |
| `low`       | Decimal(76, 20)        | Low value                                     |
| `close`     | Decimal(76, 20)        | Close value                                   |

The index is quoted in **annualised volatility percentage points**: a value of `55.21` means a 55.21% annualised IV.

#### Example: latest BTC and ETH DVOL

```sql
SELECT
    timestamp,
    market,
    close
FROM public_data.volatility_index
WHERE exchange = 'deribit'
  AND market IN ('BTC', 'ETH')
  AND timestamp >= now() - INTERVAL 24 HOUR
ORDER BY timestamp DESC, market ASC
LIMIT 50
```

#### Example: 1-hour resampled DVOL

The raw bars are at 1-minute resolution. Aggregate to whatever interval you need:

```sql
SELECT
    toStartOfHour(timestamp) AS hour,
    market,
    argMin(open, timestamp)  AS open,
    max(high)                AS high,
    min(low)                 AS low,
    argMax(close, timestamp) AS close
FROM public_data.volatility_index
WHERE exchange = 'deribit'
  AND market = 'BTC'
  AND timestamp >= now() - INTERVAL 7 DAY
GROUP BY hour, market
ORDER BY hour ASC
```

#### Example: realised vs implied (DVOL) spread

Pair the index against realised vol from `api.ohlcv` to spot dislocations:

```sql
WITH dvol AS (
    SELECT
        toStartOfDay(timestamp) AS day,
        avg(close)              AS dvol_close
    FROM public_data.volatility_index
    WHERE exchange = 'deribit'
      AND market = 'BTC'
      AND timestamp >= now() - INTERVAL 30 DAY
    GROUP BY day
),
returns AS (
    SELECT
        toStartOfDay(start) AS day,
        toFloat64(close)    AS close
    FROM api.ohlcv(candle_duration_in_minutes = 1440)
    WHERE exchange = 'binance'
      AND market = 'BTC-USDT'
      AND start >= now() - INTERVAL 31 DAY
),
realised AS (
    SELECT
        day,
        100.0 * sqrt(365)
              * stddevSamp(log(close / lagInFrame(close, 1) OVER (ORDER BY day))) AS rv30
    FROM returns
)
SELECT
    d.day,
    d.dvol_close                       AS dvol,
    r.rv30                             AS realised_30d_annualised,
    d.dvol_close - r.rv30              AS premium
FROM dvol d
LEFT JOIN realised r USING (day)
ORDER BY day ASC
```

A positive `premium` (DVOL > realised) is the typical state — option sellers earn the spread on average. Spikes in `realised` above `dvol` flag tail-risk events.

## REST API

## Get volatility index OHLC

> Returns OHLC (open / high / low / close) of an exchange's published\
> volatility index for a given underlying. Currently the primary\
> source is Deribit's DVOL (BTC and ETH).\
> \
> This endpoint is limited to 10000 records per request.<br>

```json
{"openapi":"3.1.1","info":{"title":"Koinju Market Data API","version":"1.0.0"},"servers":[{"url":"https://api.koinju.io","description":"Koinju API Server"}],"security":[{"apiKeyAuth":[]}],"components":{"securitySchemes":{"apiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"Required for /ohlcv and /trade endpoints.\nPass your API key in the x-api-key header.\nPublic /market/* endpoints do not require authentication.\n"}}},"paths":{"/volatility-index":{"get":{"summary":"Get volatility index OHLC","description":"Returns OHLC (open / high / low / close) of an exchange's published\nvolatility index for a given underlying. Currently the primary\nsource is Deribit's DVOL (BTC and ETH).\n\nThis endpoint is limited to 10000 records per request.\n","tags":["market_data"],"parameters":[{"name":"exchange","in":"query","required":true,"description":"Exchange that publishes the index (e.g. `deribit`).","schema":{"type":"string"}},{"name":"market","in":"query","required":true,"description":"Underlying asset (e.g. `BTC`, `ETH`).","schema":{"type":"string"}},{"name":"start_datetime","in":"query","required":true,"description":"Window start in ISO 8601 (e.g. `2026-03-01T00:00:00Z`) or any\nformat parseable by `parseDateTime64BestEffort`.\n","schema":{"type":"string","format":"date-time"}},{"name":"end_datetime","in":"query","required":true,"description":"Window end in ISO 8601.","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"time":{"type":"string","format":"date-time","description":"Bar timestamp (UTC)"},"exchange":{"type":"string","description":"Exchange that publishes the index"},"market":{"type":"string","description":"Underlying asset"},"open":{"type":"number","format":"decimal","description":"Open value of the index for the bar"},"high":{"type":"number","format":"decimal","description":"High value"},"low":{"type":"number","format":"decimal","description":"Low value"},"close":{"type":"number","format":"decimal","description":"Close value"}}}}}}}}}}}}
```


---

# 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.koinju.io/data/volatility-index.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.
