---
title: "Get Gex Historical Context"
method: GET
path: "/api/gex/historical-context"
tags: ["GEX"]
---

# Get Gex Historical Context

`GET /api/gex/historical-context`

## Request

- Base URL: `https://api.zerogex.io` (the document declares no server; this is the origin it was published from)
- URL: `https://api.zerogex.io/api/gex/historical-context`
- Auth: HTTP bearer

Historical-distribution context for the live headline GEX metrics.

For each of ``net_gex_at_spot`` and ``total_net_gex``, returns the
current value plus the rolling-30-day and all-time distributions
(p05/p25/p50/p75/p95, mean/std, min/max, sample size), the live value's
interpolated percentile and z-score against each window, and a regime
label (``record_high`` / ``extreme_high`` / ``elevated`` / ``normal`` /
``low`` / ``extreme_low`` / ``record_low`` / ``unknown``).

Distribution rows are produced nightly by
``src.tools.gex_historical_stats_refresh`` and bucketed by 5-minute ET
RTH bucket so the EOD-pinning seasonality doesn't dominate the
comparison.  Falls back to a flat (no TOD bucketing) distribution when
a specific bucket is thin.

Returns 404 if no ``gex_summary`` row exists for the symbol yet.

## Query parameters

- `symbol` string

## Response `200`

Successful Response

- GEXHistoricalContext: Response shape for ``/api/gex/historical-context``. Headline GEX figures from the latest ``gex_summary`` row alongside the historical-distribution context (30d + all_time, TOD-aware) for each. The frontend uses this to render "P82 vs 30d", "EXTREME HIGH", "elevated" style badges on the live MetricCards (with a trophy icon overlay when the value is a record for that window) and a dedicated /gamma-pulse page. ``tracking_started_at`` is the earliest ``gex_summary.timestamp`` for the symbol — the "since YYYY-MM-DD" date the all-time-record trophy tooltip cites.
  - `symbol` string, required
  - `timestamp` string, date-time, required
  - `tod_bucket` integer, nullable
  - `in_rth` boolean, required
  - `tracking_started_at` string, date-time, nullable
  - `metrics` object, required

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/zerogex/apis/zerogex-api.md) · [All operations](https://skmtc.dev/zerogex/apis/zerogex-api/llms.txt) · [OpenAPI document](https://skmtc.dev/zerogex/apis/zerogex-api/revisions/753b26bf0592?raw)
