> Every Taji docs page as Markdown: https://docs.taji.is/llms.txt

# Chart dealer gamma exposure

The GEX plugin estimates dealer gamma exposure from an option chain; you draw its levels and its profile by strike on a chart, then read the same figures over the wire.

You need Taji built from source (`cargo build -p taji-open`) and the plugin built in its own directory. `taji plugin dev` plays the plugin's own recording, `plugins/taji-gex/fixtures/`, as if it were live; the example's `dev` file has the capture do the same:

```sh
(cd plugins/taji-gex && cargo build)
target/debug/taji plugin dev plugins/taji-gex
```

> [!IMPORTANT]
> Everything below is that recording: made-up option chains for `index:$SPX` around 6,000, round strikes, open interest and implied volatility, played in a loop. The chart says so with its **Taji replay** tag. It is not live data, and its figures are not the market's. On your own Taji, stage the plugin under `TAJI_PLUGINS` ([Install a plugin](https://docs.taji.is/plugins.md)) and bind its layers to any chart whose symbol a linked provider serves a chain for.

`plugin dev` opens a desk with chart 1 on `index:$SPX`'s 1-minute candles and binds the plugin's three chart layers and its two scripts, the same ones the indicator catalog lists under Plugins. `calls.json` then opens the product's stream and reads the levels and the profile by strike:

```json file="examples/gex-profile/calls.json" title="calls.json"
[
  {"name": "stream", "stream": "/ws/market", "body": {"type": "stream", "id": "gex", "product": "taji-gex.levels", "symbols": ["index:$SPX"], "lens": "gamma"}, "take": 2},
  {"name": "levels", "method": "GET", "route": "/get/taji-gex.levels?symbols=index:$SPX&lens=gamma", "until": "length >= 1"},
  {"name": "strikes", "method": "GET", "route": "/get/taji-gex.strikes?symbols=index:$SPX&lens=gamma", "until": "length >= 1", "shot": true}
]
```

![A 1-minute chart of the replayed S&P 500 tagged Taji replay, with the GEX levels drawn at the right: a gold flip line at 6,093.96, a magnet at 6,150 and the put wall and max pain at 6,050, each tagged on the price axis; at the right edge two docks, the curve's net exposure by hypothetical spot and the profile's bars by strike, a long pink one at 6,150 and a green one at 5,950; below, the two script panes](https://raw.githubusercontent.com/TajiAI/Taji/main/docs/cookbook/examples/gex-profile/shot.png)

1. **The layers** are the three `[[ui.layers]]` rows of `plugins/taji-gex/taji-plugin.toml`, bound with `params: {}`, every word at its default: `lens` `gamma`, `expiries` `all`, `units` `usd`, and a window of 15% around spot. A layer computes nothing in the kernel: the window reads its product and draws it. `GEX levels` draws a row of `taji-gex.levels` as horizontal lines, the flip solid. `GEX profile` and `GEX curve` draw `taji-gex.strikes` and `taji-gex.curve` in docks at the right edge, green where the net is positive and pink where it is negative.
2. **`stream`** opens `/ws/market` and asks for `taji-gex.levels` on `index:$SPX`. The plugin's history is only the snapshots Taji has held, so on a new Taji a read finds nothing until a stream has the plugin price a live chain. The window streams each layer it draws; with no window open, your client streams the product itself.
3. **`levels`** is `GET /get/taji-gex.levels`, repeated a second apart until it answers a row (`until`).
4. **`strikes`** is `GET /get/taji-gex.strikes`, the strikes within the default 15% of spot. `shot` photographs the chart once the calls are done.

The stream's first two frames, the socket's hello and the first row the plugin priced:

```json file="examples/gex-profile/stream.json"
[
  {
    "header": {
      "type": "hello",
      "seq": 0
    }
  },
  {
    "header": {
      "type": "rows",
      "id": "gex",
      "history": false,
      "seq": 1
    },
    "rows": [
      {
        "ts_utc": 1796408644,
        "spot": 6120,
        "net": -63218722.651855946,
        "calls": 39210729.391658336,
        "puts": -102429452.04351428,
        "same_day": 580939.8961673188,
        "above_spot": -63389666.57895056,
        "below_spot": 170943.92709462345,
        "flip": 6093.9608642578,
        "call_wall": null,
        "put_wall": 6050,
        "magnet": 6150,
        "max_pain": 6050,
        "oi_date": null,
        "knowable_utc": 1796408645,
        "recorded": false,
        "version": "0.1.0"
      }
    ]
  }
]
```

The levels, one row per chain snapshot:

```json file="examples/gex-profile/levels.json"
[
  {
    "ts_utc": 1796408644,
    "spot": 6120,
    "net": -63218722.651855946,
    "calls": 39210729.391658336,
    "puts": -102429452.04351428,
    "same_day": 580939.8961673188,
    "above_spot": -63389666.57895056,
    "below_spot": 170943.92709462345,
    "flip": 6093.9608642578,
    "call_wall": null,
    "put_wall": 6050,
    "magnet": 6150,
    "max_pain": 6050,
    "oi_date": null,
    "knowable_utc": 1796408644,
    "recorded": true,
    "version": "0.1.0"
  }
]
```

- `spot` is the recording's price when the chain was priced, 6,120, at `ts_utc`. Every figure but `spot`, `max_pain` and `oi_date` is an estimate.
- With the `gamma` lens and `usd` units, each exposure is in dollars per 1% move in the index, as the product's `model` states. `net` is about −$63 million, the sum of `calls` (+$39 million) and `puts` (−$102 million), dealers assumed long calls and short puts. `same_day` is the part from the expiries ending today, `above_spot` and `below_spot` the parts from the strikes on each side.
- `flip`, about 6,094, is the price where net exposure crosses zero, found by repricing the chain at hypothetical spots: the zero of the curve dock. Spot is above it, so net exposure is negative.
- `call_wall` is `null`: no strike at or above spot has a positive net. `put_wall`, 6,050, is the strike at or below spot with the most negative net. `magnet` is the strike of the largest absolute net, 6,150. `max_pain`, 6,050, is the front expiry's strike of least payout to option holders.
- `oi_date`, the date of the open interest, is `null`: the recording states none.
- The kernel adds `knowable_utc`, `recorded` and `version` to every plugin row ([the protocol](https://docs.taji.is/plugins/protocol.md)); `version` names the plugin version that computed it.

The profile by strike, net and its parts:

```json file="examples/gex-profile/strikes.json"
[
  {
    "ts_utc": 1796408644,
    "price": [
      5900,
      5950,
      6050,
      6150
    ],
    "value": [
      -4.631933813064908e-12,
      38629789.49549102,
      -38458845.5683964,
      -63389666.57895056
    ],
    "calls": [
      0.0,
      38629789.49549102,
      580939.8961673188,
      0.0
    ],
    "puts": [
      -4.631933813064908e-12,
      0.0,
      -39039785.46456371,
      -63389666.57895056
    ],
    "d0": [
      -4.631933813064908e-12,
      0.0,
      580939.8961673188,
      0.0
    ],
    "d1_7": [
      0.0,
      0.0,
      0.0,
      0.0
    ],
    "d8_30": [
      0.0,
      38629789.49549102,
      -39039785.46456371,
      -63389666.57895056
    ],
    "d31_60": [
      0.0,
      0.0,
      0.0,
      0.0
    ],
    "d61_120": [
      0.0,
      0.0,
      0.0,
      0.0
    ],
    "d121": [
      0.0,
      0.0,
      0.0,
      0.0
    ],
    "knowable_utc": 1796408644,
    "recorded": true,
    "version": "0.1.0"
  }
]
```

*Captured 2026-12-04 on `taji plugin dev plugins/taji-gex --headless`, playing the plugin's made-up `fixtures/`. The replay follows the wall clock, so a recapture can land on another snapshot of the loop.*

- `price` holds the recording's strikes, 5,900, 5,950, 6,050 and 6,150, and each other list holds one value per strike, in the same order. `value` is the net, `calls` and `puts` its two sides, and `d0` to `d121` the net split by days to expiry.
- The most negative net, about −$63 million, is at 6,150, the magnet: the long pink bar in the profile dock. The most negative at or below spot, about −$38 million, is at 6,050, the put wall. The one positive net, about $39 million, is at 5,950, below spot, so there is no call wall.
- `d0` is the part from the contracts expiring today: only 6,050 carries any.

## Change it

Count only the contracts that expire today:

```diff
-  {"name": "levels", "method": "GET", "route": "/get/taji-gex.levels?symbols=index:$SPX&lens=gamma", "until": "length >= 1"},
+  {"name": "levels", "method": "GET", "route": "/get/taji-gex.levels?symbols=index:$SPX&lens=gamma&expiries=0dte", "until": "length >= 1"},
```

Read vanna instead of gamma; `lens` also takes `delta`, `charm`, `vega`, `iv_oi` and `oi`:

```diff
-  {"name": "levels", "method": "GET", "route": "/get/taji-gex.levels?symbols=index:$SPX&lens=gamma", "until": "length >= 1"},
+  {"name": "levels", "method": "GET", "route": "/get/taji-gex.levels?symbols=index:$SPX&lens=vanna", "until": "length >= 1"},
```

Read only the strikes within 1% of spot:

```diff
-  {"name": "strikes", "method": "GET", "route": "/get/taji-gex.strikes?symbols=index:$SPX&lens=gamma", "until": "length >= 1", "shot": true}
+  {"name": "strikes", "method": "GET", "route": "/get/taji-gex.strikes?symbols=index:$SPX&lens=gamma&window_pct=1", "until": "length >= 1", "shot": true}
```

## Next

- [GEX](https://docs.taji.is/catalog/taji-gex.md): the four products, their words, the two script indicators and how history is kept.
- [Draw a chart layer](https://docs.taji.is/plugins/layer.md): the stock renderers these layers use, and the profile's shader.
- [Build a feature plugin](https://docs.taji.is/plugins/feature.md): a product, a layer and a script of your own.
