Skip to main content
Glama
deribit-options-analytics

deribit-options-analytics

by tordagaz-ops
README.md
# deribit-options-analytics

**English** · [Español](README.es.md) · [Русский](README.ru.md)

An MCP server that answers option questions about **Deribit** with arithmetic
you can check, not vibes. Every greek is repriced from the venue's own mark IV,
every dollar figure is derived from that chain, and every number in this
document was measured on the live venue — the date is printed with the table.

Ask it:

- *Where does the BTC book feel the most pain on Friday?*
- *Which strike is the dealer gamma wall, and is gamma positive above spot?*
- *What is the 25-delta risk reversal telling me — are puts bid or offered?*
- *What implied move is the market pricing for the weekly?*
- *What did the whole BTC chain do in the last five minutes?*

```
BTC-27NOV26 max pain        71,000   (+16.8 % from spot)
BTC all expiries, gamma    -78.4 M USD per 1 %   puts -207.5 M, calls +129.1 M
BTC nearest, 30d IV        43.2 %    expected move 1.96 %
BTC Feb-27, 25d RR         -679 bps  butterfly +109 bps
```

No API key. No account. Deribit's public endpoints answer anonymously, so the
server works the moment it is installed.

## Contents

- [What it does](#what-it-does)
- [The arithmetic, stated plainly](#the-arithmetic-stated-plainly)
- [The day count is measured, not assumed](#the-day-count-is-measured-not-assumed)
- [Term structure as measured](#term-structure-as-measured)
- [Max pain as measured](#max-pain-as-measured)
- [Gamma as measured](#gamma-as-measured)
- [Skew as measured](#skew-as-measured)
- [A chain row, and what each field means](#a-chain-row-and-what-each-field-means)
- [The six tools](#the-six-tools)
- [Install](#install)
- [Run](#run)
- [Configure your client](#configure-your-client)
- [Docker](#docker)
- [Errors](#errors)
- [Tests](#tests)
- [Why one venue is modelled in full](#why-one-venue-is-modelled-in-full)
- [Design notes](#design-notes)
- [Locales](#locales)
- [Licence](#licence)

## What it does

Six read-only tools over the public Deribit v2 API. Nothing is written, no
order is ever placed, and no credential is read:

| Tool | The question it answers |
| --- | --- |
| `expiry_summary` | List every expiry with forward, ATM IV, expected move, open interest and put/call ratio. |
| `option_chain` | One expiry, one row per strike, with IV, delta, gamma and dollar gamma. |
| `max_pain` | The strike where option holders' payout is smallest — per expiry or across the book. |
| `gamma_walls` | Net dealer gamma by strike: the walls, the flip point, and which way it pushes. |
| `iv_skew` | The smile in vol points: ATM IV, 25-delta and 10-delta risk reversals, butterfly, slope. |
| `list_venues` | Which option venues answer, and how fast. |

The venue is a **parameter**, not a fork. A second venue is one class and one
tuple entry; the tools, the maths and the error contract do not change. See
[Why one venue is modelled in full](#why-one-venue-is-modelled-in-full).

## The arithmetic, stated plainly

Deribit options are **inverse and coin-settled**: the premium is quoted in the
underlying coin, one contract is one coin, and settlement happens in coin. So
the model has to price a call that pays `(S − K)/S` in BTC, not `(S − K)` in
dollars. Under Black-Scholes with zero rates that is exactly

```
coin premium of a call = N(d1) − (K/F)·N(d2)
coin premium of a put  = (K/F)·N(−d2) − N(−d1)
USD premium            = coin premium × forward
```

where `F` is the forward for that expiry, computed from the venue's own
`underlying_price`, and

```
d1 = [ln(F/K) + ½σ²t] / (σ√t),    d2 = d1 − σ√t
delta_call = N(d1)                delta_put = N(d1) − 1
gamma = N′(d1) / (F·σ√t)          vega  = F·N′(d1)·√t
```

Two consequences worth knowing before you use the output:

1. **A call's delta is `N(d1)`, between 0 and 1**, and a put's is between −1 and
   0 — the same convention as any other book. There is no coin/dollar delta
   ambiguity in the payload: `delta` is per coin and `gamma_usd_per_1pct` is
   already in dollars.
2. **Dollar gamma per 1 % move is `gamma · F² · 0.01` per contract.** The payload
   reports it per contract in the chain and multiplied by open interest in the
   walls and profile, because that is where it means something. A wall of
   "0 USD" next to a strike with 4,800 contracts of open interest was a bug in
   this server once; the field name `net_gex_usd_per_1pct` now always includes
   open interest.

Zero discounting is not a shortcut, it is the venue: Deribit's `interest_rate`
is 0.0 and premium is paid in coin, so the forward already carries the carry and
the coin premium needs no discount factor.

## The day count is measured, not assumed

The single choice that moves the answer most is how a year is counted. Rather
than pick one, we repriced **every live BTC option (1,007 priced contracts)** from
its own `mark_iv` under three conventions and compared the model premium with the
venue's mark. Measured 2026-11-26 14:00 UTC:

| Day count | Median relative error | 90th percentile | Verdict |
| --- | --- | --- | --- |
| ACT/365 | **0.008 %** | **0.055 %** | used |
| ACT/365.25 | 0.032 % | 0.280 % | 4× worse at the median |
| ACT/360 | 0.637 % | 4.914 % | 82× worse at the median |

The gap is not noise, and it is not one lucky run either: across four runs on the
same day the median error was 0.005–0.022 % for ACT/365, 0.030–0.042 % for
ACT/365.25 and 0.61–0.64 % for ACT/360, always in that order, across the whole
distribution rather than at one percentile. That is what you would expect from a
venue whose expiries are always at 08:00 UTC. So `DAYS_PER_YEAR = 365.0` is a
measurement, and the table above is the evidence.

That the model reproduces the venue's marks to 0.008 % at the median is also the
main correctness test of this server: if the inverse-premium formula, the
forward or the expiry timestamp were wrong, this number would be in the
per-cent range, not the per-basis-point range.

## Term structure as measured

`expiry_summary` on BTC, 2026-11-26 14:00 UTC, spot 60,798.92:

| Expiry | Days | Forward | ATM IV | Expected move | Open interest (USD) | Put/call |
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026-11-27 | 0.75 | 60,809.91 | 43.24 % | 1.96 % | 6,898,099,842 | 0.85 |
| 2026-11-28 | 1.75 | 60,813.79 | 42.08 % | 2.91 % | 92,126,810 | 0.93 |
| 2026-11-29 | 2.75 | 60,825.22 | 37.50 % | 3.25 % | 55,083,319 | 2.64 |
| 2026-11-30 | 3.75 | 60,827.77 | 39.61 % | 4.01 % | 0 | — |
| 2026-12-04 | 7.75 | 60,847.68 | 48.57 % | 7.08 % | 1,628,210,900 | 1.44 |
| 2026-12-11 | 14.75 | 60,882.71 | 51.81 % | 10.41 % | 709,107,012 | 1.25 |

The whole chain is **1,036 options across 13 expiries** and arrives in one
request: **155 ms** measured end to end, including deserialising 563 KB and
repricing all of it. ETH answered the same question with **824 options across 13
expiries** and a spot of 1,702.10.

Two things the table shows honestly rather than hiding:

- `2026-11-30` (and `2026-12-18`) have IV and an expected move but **zero open
  interest**: the venue lists expiries before anyone trades them. `max_pain` on
  such an expiry returns `no_open_interest` instead of inventing a strike, and
  the tools note it rather than silently dropping the date.
- Expected move is one standard deviation to expiry in per-cent of forward, not
  a confidence interval: `ATM IV × √t`.

## Max pain as measured

`max_pain` prices, for every candidate strike, the total coin payout that would
be exercised if the expiry settled there, converts it at the forward, and
reports the minimum. Measured 2026-11-26:

| Expiry | Max pain | Distance from spot | Payout at that strike |
| --- | ---: | ---: | ---: |
| 2026-11-27 | 71,000 | +16.76 % | 185,131,900 USD |
| 2026-11-28 | 59,500 | −2.16 % | 88,250 USD |
| 2026-11-29 | 59,500 | −2.18 % | 103,250 USD |
| 2026-12-04 | 63,000 | +3.54 % | 8,028,700 USD |
| 2026-12-11 | 62,000 | +1.84 % | 2,829,800 USD |
| 2026-12-25 | 70,000 | +14.74 % | 241,336,200 USD |
| all expiries | 70,000 | +15.13 % | — |

The two distant readings are not a bug, and this is exactly the kind of thing a
paid tool owes you rather than a smoothed number: those expiries carry thousands
of **in-the-money puts** at 63,000–70,000 (2026-11-27 alone holds 2,931.9 puts at
63,000 and 3,006.7 at 70,000), so the cheapest settlement for the book really is
above spot, where those puts expire worthless. Whether "max pain" is a
meaningful signal is a separate question; the tool reports the arithmetic, and
`pain_usd` tells you how flat the minimum is — at 2026-11-28 the total payout is
88 thousand dollars, i.e. nothing to defend.

`nearest` gives the three closest strikes to the minimum and `curve` the payout
at every candidate, so you can see how flat the bottom is instead of trusting a
single point.

## Gamma as measured

`gamma_walls` with the default dealer convention (calls add gamma, puts subtract
it), all expiries, BTC, 2026-11-26:

| Quantity | Value |
| --- | ---: |
| Net gamma, calls | +129,100,312 USD per 1 % |
| Net gamma, puts | −207,456,132 USD per 1 % |
| **Net gamma, book** | **−78,355,820 USD per 1 %** |
| Call wall | 66,000 |
| Put wall | 58,000 |
| Flip strike | none (cumulative never crosses zero) |
| Strikes in the profile | 94 |

Nearest expiry alone: **−28,590,527 USD per 1 %**, call wall 60,500, put wall
62,000. Note that the call wall can print *below* the put wall: the walls are the
strongest positive and the strongest negative strike, not an ordered pair, and a
book with puts bid above spot will show it.

The flip is `null` here and that is the honest answer: the cumulative profile
starts negative at the lowest strike and never crosses zero, so there is no
strike where dealer gamma changes sign. The tool says so in `notes` rather than
reporting the nearest strike it can find. When the cumulative does cross — a
put-heavy top and a call-heavy bottom — `flip_strike` appears with
`flip_vs_forward_pct`.

The `convention` parameter switches to `absolute`, which sums unsigned gamma when
you want gross exposure rather than a directional read.

## Skew as measured

| Expiry | Days | ATM IV | 25-delta RR | 10-delta RR | Butterfly | Slope | Quotes |
| --- | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
| 2026-11-27 | 1 | 43.24 % | +334 bps | +459 bps | +95 bps | +11.88 pt / 10 % | 14 |
| 2026-11-30 | 4 | 39.61 % | −207 bps | −648 bps | +91 bps | −3.81 pt / 10 % | 24 |
| 2027-02-26 | 92 | 46.15 % | −679 bps | −1,232 bps | +109 bps | −2.10 pt / 10 % | 58 |

Risk reversal is calls minus puts in basis points of vol: negative means puts are
bid, the normal state of a crypto smile. The butterfly is the same measure of how
much the wings bulge over ATM. The slope is a least-squares fit of IV against
log-moneyness in **vol points per 10 % strike move**.

Two caveats printed in the payload rather than buried:

- The one-day expiry reads **positive** (+334 bps) and its slope is **+11.88**,
  because at 0.75 days the call wing is bid and the fitted line is steep. The same
  expiry quotes **149.2 % IV** at a strike with no market at all. A one-day smile
  is a gamma story, not a skew story, and the payload gives you `days_to_expiry`
  so you can see it.
- The slope deliberately **does not fit the whole chain**. Wings are excluded by
  absolute delta (0.10 to 0.90). Measured on the same day, fitting every quote
  produced **+9.44 pt/10 %** on one expiry and **−16.93** on the next — the sign
  flipped between neighbouring expiries, which is a description of noise, not of
  a smile. `slope_quotes` reports how many quotes survived the filter: 14 for the
  one-day expiry, which is why its number deserves doubt.

`by_delta` gives put and call IV at fixed deltas (10, 25, 50), interpolated from
OTM quotes only, so the points are always on a traded side of the smile.
`min_iv_pct` and `max_iv_pct` are the quoted range of that expiry, which is how
the 149.2 % wing becomes visible instead of silently shifting a curve.

## A chain row, and what each field means

`option_chain` row for the busiest strike of the nearest BTC expiry, 2026-11-26:

```json
{
  "instrument": "BTC-27NOV26-63000-P",
  "strike": 63000.0,
  "type": "put",
  "expiry": "2026-11-27",
  "iv_pct": 53.85,
  "delta": -0.9247,
  "gamma": 9.565254469e-05,
  "open_interest": 2931.9,
  "open_interest_usd": 178288575.13,
  "volume_usd": 74763.97,
  "bid": 0.0355,
  "ask": 0.039,
  "mid": 0.03725,
  "mark": 0.03681489,
  "spread_bps": 939.6,
  "moneyness": 1.036,
  "gamma_usd_per_1pct": 3537.08
}
```

| Field | Unit | Meaning |
| --- | --- | --- |
| `bid`, `ask`, `mid`, `mark` | coin | Premium, not dollars. `null` when that side is empty. |
| `iv_pct` | per cent | The venue's `mark_iv`, the same number the model is checked against. |
| `delta` | per coin | `N(d1)` for calls, `N(d1) − 1` for puts. |
| `gamma` | per coin, per coin | `N′(d1) / (F σ √t)`. |
| `gamma_usd_per_1pct` | USD | `gamma · F² · 0.01` for **one** contract. |
| `open_interest` | contracts | One contract is one coin. |
| `open_interest_usd` | USD | `open_interest × forward`, notional. |
| `volume_usd` | USD | The venue's own volume field, passed through. |
| `spread_bps` | basis points | `(ask − bid) / mid`, `null` on a one-sided book. |
| `moneyness` | ratio | `strike / forward`. Above 1 is an out-of-the-money call. |

A field can be `null` for a real reason: `BTC-27NOV26-90000-C` on the same day had
**4,791.8 contracts of open interest, a 127.75 % mark IV and no mark price at
all** — a one-tick ask of 0.0001 with no bid. Open interest without a market is a
state the venue allows, and the payload leaves the price fields empty rather than
inventing them from the model.

## The six tools

Every tool returns a dict, is annotated `readOnlyHint` and `openWorldHint`, and
never raises. Common envelope on chain-based tools: `symbol`, `venue`, `spot`,
`contracts`, `as_of`, plus `notes` when something needs saying.

### `expiry_summary`

```json
{"symbol": "BTC", "window": "all"}
```

`window` is `week`, `month`, `quarter` or `all`; `limit` caps the number of
expiries (1–40, default 12). Each expiry carries `forward`,
`forward_vs_spot_pct`, `atm_iv_pct`, `atm_strike`, `expected_move_pct`,
`expected_move_usd`, `open_interest`, `open_interest_calls`,
`open_interest_puts`, `open_interest_usd`, `put_call_ratio`, `volume_usd`,
`strikes` and `contracts`. Alongside `expiries` the payload carries `count`,
`truncated`, and a `total` block with the open-interest-weighted ATM vol of the
window and the earliest and latest expiry in it.

### `option_chain`

```json
{"symbol": "BTC", "expiry": "2026-12-25", "sort": "oi", "limit": 20,
 "min_open_interest": 10}
```

`expiry` accepts `YYYY-MM-DD` or `YYYY-MM` (the first expiry of that month);
omitted means the nearest listed expiry. `sort` is one of `oi`, `volume`,
`strike`, `iv`, `gamma`, `delta`. `limit` is 1–200 (default 40), and
`min_open_interest` filters in contracts. The rows are the fields in the table
above; `expiry`, `days_to_expiry`, `summary` (the same object
`expiry_summary` returns for that date), `count` and `truncated` sit beside them.

### `max_pain`

```json
{"symbol": "BTC", "expiry": "2026-11-27", "top": 3}
```

Returns `max_pain`, `pain_usd`, `distance_pct`, `strikes_considered`, `nearest`
(the closest strikes with their payout) and `curve`. Omit `expiry` to aggregate
the whole book, where `distance_pct` is measured from spot.

### `gamma_walls`

```json
{"symbol": "BTC", "convention": "dealer_calls_long", "top": 6}
```

Returns `total_gex_usd_per_1pct`, `call_gamma_usd_per_1pct`,
`put_gamma_usd_per_1pct`, `call_wall`, `put_wall`, `flip_strike`,
`flip_vs_forward_pct`, `convention`, `walls_above`, `walls_below` and a
`profile` of `strike`, `net_gex_usd_per_1pct`, `cumulative_usd_per_1pct`
(trimmed to the 60 strikes nearest spot, with `profile_truncated` saying so).

### `iv_skew`

```json
{"symbol": "BTC", "expiry": "2027-02-26"}
```

Omit `expiry` for every expiry (`limit` caps how many, default 12). Each smile
carries `atm_iv_pct`, `atm_strike`, `risk_reversal_25d_bps`,
`risk_reversal_10d_bps`, `butterfly_25d_bps`, `slope_vol_points_per_10pct`,
`slope_quotes`, `min_iv_pct`, `max_iv_pct` and `by_delta`.

### `list_venues`

```json
{"probe": true}
```

Reports the configured venues, their currencies, their cache TTL and — with
`probe` — a live latency and contract count. `probe: false` answers from the
registry without touching the network, which is useful when the venue is down.

## Install

```bash
git clone https://github.com/tordagaz-ops/deribit-options-analytics
cd deribit-options-analytics
python -m venv .venv
# Windows
.venv\Scripts\activate
# macOS / Linux
source .venv/bin/activate
pip install -e .
```

Python 3.10 or newer. One runtime dependency (`httpx`) plus `mcp`.

## Run

```bash
python -m mcp_deribit_options
```

`MCP_TRANSPORT` selects the transport; the default is `stdio`, which is what MCP
clients expect:

```bash
MCP_TRANSPORT=stdio     python -m mcp_deribit_options   # default
MCP_TRANSPORT=sse       python -m mcp_deribit_options
MCP_TRANSPORT=streamable-http python -m mcp_deribit_options
```

## Configure your client

```json
{
  "mcpServers": {
    "deribit-options-analytics": {
      "command": "python",
      "args": ["-m", "mcp_deribit_options"],
      "env": { "MCP_LOCALE": "en" }
    }
  }
}
```

Via Smithery:

```bash
npx -y @smithery/cli install deribit-options-analytics --client claude
```

## Docker

```bash
docker build -t deribit-options-analytics .
docker run -i --rm deribit-options-analytics
```

The image runs as a non-root user, installs only the runtime dependency and
speaks stdio on stdin/stdout, so `-i` is required and `-t` is not.

## Errors

Failures are values, never exceptions. Every error is
`{"error": "<code>", "message": "<localized>", ...}`:

| Code | When |
| --- | --- |
| `bad_symbol` | The underlying is not one this venue lists. |
| `unknown_symbol` | The venue itself does not know the instrument. |
| `bad_expiry` | An expiry that is not `YYYY-MM-DD`, `YYYY-MM`, or is not listed. |
| `invalid_limit` / `invalid_sort` / `invalid_window` / `invalid_convention` | A parameter outside its allowed set. |
| `invalid_number` | A numeric argument that is not a number. |
| `unknown_venue` | A venue that is not configured. |
| `no_open_interest` | The expiry exists but nothing has traded. |
| `no_data` | The venue answered but the requested slice is empty. |
| `timeout` / `network_error` | The venue did not answer. Retry is safe: every tool is read-only. |
| `upstream_rejected` / `upstream_unavailable` | The venue refused or is down. |
| `bad_payload` | The venue answered with something that is not the documented shape. |

A partial answer beats none: if one expiry of a multi-expiry request fails, the
rest are returned and `notes` says which one was skipped.

## Tests

```bash
pytest -q            # 189 offline
pytest -m live -q    # 12 live, needs the network
```

| Layer | Tests | What it proves |
| --- | ---: | --- |
| Unit (`tests/test_unit.py`) | 91 | The arithmetic: inverse premiums against a closed-form oracle, greeks against finite differences, ACT/365, max pain on a hand-computed book, walls and flip on constructed profiles, smile fitting. |
| Tools (`tests/test_tools.py`) | 76 | Every tool through a real MCP client session on a replayed recording: payload shapes, every error code, argument validation, locales. |
| End to end (`tests/test_e2e.py`) | 22 | A real subprocess speaking JSON-RPC over stdio: handshake, tool list, calls, a rejected argument coming back as JSON rather than a crash. |
| Live (`tests/test_live.py`) | 12 | The real venue: contract counts, repricing accuracy, that the name-decode matches the venue's own fields. |

The offline layers replay a recording made from the live API
(`tests/fixtures/deribit.json`), served through `httpx.MockTransport`, so `pytest`
needs no network and gives the same answer on a plane.

Recorded data is trimmed: four expiries, eight strikes per expiry, contract fields
only. The e2e layer uses the same recording through a subprocess, which is why it
is 22 tests in about 29 seconds rather than minutes.

## Why one venue is modelled in full

Deribit is where the crypto option book is, and options are the case where one
venue *is* the market: there is no cross-exchange best execution to aggregate,
because the same contract does not exist on another exchange with the same
settlement. So the venue is a parameter on every tool, and a second one is a
class with `book_summary`, `index_price`, `instruments` and `chain`, plus one
entry in `VENUE_NAMES`. The maths, the tool contracts and the error codes are
venue-independent.

What is Deribit-specific is documented as such: inverse coin premium, one
contract = one coin, 08:00 UTC expiries, `mark_iv` as the source of truth, and
the JSON-RPC envelope on top of HTTP.

## Design notes

- **`server.py` has no `from __future__ import annotations`.** FastMCP resolves
  type hints at runtime and lazy annotations break it.
- **Parameters are annotated `list[str] | str`, `float | str`, `int | str`,
  `bool | str`** and validated in the body, because FastMCP validates before the
  tool runs and a schema rejection would not be our JSON error contract.
- **Undeclared arguments are ignored by the SDK, not rejected.** Verified end to
  end: `list_venues({"venue": "nope"})` returns a normal payload. The e2e layer
  asserts that ignored-argument behaviour instead of assuming a rejection.
- **The chain cache is 5 seconds and caches the raw payload, not the parsed
  chain**, because greeks depend on `now` and a cached `Chain` would carry stale
  time-to-expiry.
- **Prices are formatted with `.10g`**, never `round(x, 6)`: a 0.0001 premium is
  a real price and must not collapse to 0.0.
- **The instrument name is enough.** `BTC-27NOV26-63000-P` carries currency,
  expiry, strike and type, so `/get_instruments` (905 KB) is not needed at
  runtime. It stays in the adapter so the claim remains falsifiable — and the
  live layer checks the decode against the venue's own `expiration_timestamp`,
  `strike` and `option_type` fields for all 1,036 instruments.

## Locales

`MCP_LOCALE` selects the language of tool titles, descriptions, parameter
documentation, error messages and notes: `en` (default), `es`, `ru`.

```bash
MCP_LOCALE=ru python -m mcp_deribit_options
```

The payload keys and numeric fields never change with the locale — only human
text does, so a client can switch language without touching its parsing. The
three catalogues are test-verified to have identical key sets.

This page is also available in [Spanish](README.es.md) and
[Russian](README.ru.md).

## Licence

MIT. See [LICENSE](LICENSE).

Data comes from the public Deribit API and is provided as is. Nothing here is
investment advice, and a gamma wall is not a prediction.