A local, single-user dashboard for gamma exposure (GEX) and implied volatility (IV) on SPY, QQQ, and AAPL (1–30 calendar DTE). Clicking Refresh fetches one option-chain snapshot, prices it with discrete cash dividends and SOFR (ADR-0001), saves it to DuckDB, and displays:
- GEX heatmap by strike and expiration (with approximate
SPX/NDXlevels next toSPY/QQQstrikes) - 3D IV surface
- Positioning profile: call wall, put wall, GEX peaks, and max pain
- Gamma regime: net GEX at spot, gamma flip level, and vanna exposure (VEX)
Personal research tool only — not a live feed, trading system, or financial advice.
- Trigger: Run once per weekday (e.g.
09:00 ET), never in a loop. - Prerequisites: Python 3.12 only (no browser, Node.js, or server required).
git clone https://github.com/zhuy9/GEX-lens.git cd GEX-lens/backend python3.12 -m venv .venv && . .venv/bin/activate pip install -r ../scripts/requirements.txt python ../scripts/daily_heatmap.py
- Outputs generated (git-ignored under
exports/):exports/heatmap.md— Read this. Contains exact numbers (spot, gamma regime & flip, VEX, biggest strikes, walls, top expirations) plus the heatmap as a Markdown table.exports/heatmap-spy.png&exports/heatmap-qqq.png— Send these to the user. (No need to OCR them.)- Dashed lines:
spot(blue),call wall(green),put wall(red),gamma flip(orange). Levels outside the shown strikes appear as↑/↓edge labels.
- Dashed lines:
- Summary format: Follow the Section 8 checklist and template in docs/interpret-heatmap.md using values from
exports/heatmap.md. - Failure & safety rules:
UPSTREAM_ACCESS_DENIEDorUPSTREAM_RATE_LIMITED: Nasdaq blocked the request — tell the user and do not retry.DIVIDEND_REVIEW_REQUIRED: The daily data job stopped — tell the user.- Never commit generated files or local config (
daily_heatmap.pyuses temporary settings and DuckDB). - For a zero-network dry run with synthetic data, pass
--fixture(outputs are labeledSYNTHETIC FIXTURE DATA). - Before the 09:30 ET open, prices reflect the prior close and open interest reflects the overnight update. See ADR-0004.
- Cell values: Dollar gamma exposure (
gamma * OI * 100 * spot^2 * 1%) per 1% spot move — not trading volume. - Colors: Green = call gamma (
+, damping under the standard dealer-positioning assumption); red = put gamma (-, amplifying); darker = larger magnitude. - Gamma flip & VEX: Flip = spot level where net GEX changes sign; VEX = hedging flow per 1-point IV move.
- Full guide: See docs/interpret-heatmap.md for near vs. far dates, walls, academic evidence, common mistakes, and the daily summary template.
Requires Python 3.12 and Node.js 24.22.1+. Fixture mode uses synthetic data with zero network calls.
- Backend (run from
backend/; paths insettings.jsonare relative tobackend/):
cd backend python3.12 -m venv .venv && . .venv/bin/activate pip install -r requirements.txt cp settings.example.json settings.json # git-ignored; never commit it python app.py # http://127.0.0.1:8000
- Frontend (second terminal):
cd frontend npm ci npm run dev # http://127.0.0.1:5173
Open http://127.0.0.1:5173 and click Refresh.
(On Windows: use py -3.12, .venv\Scripts\Activate.ps1, and Copy-Item.)
Strict JSON (no comments or extra keys); validated at startup. Enabled symbols come from backend/instruments.py.
| Key | Allowed Values | Notes |
|---|---|---|
source_mode |
"fixture", "nasdaq" |
Option-chain source. Review Data sources & usage rights before using "nasdaq". |
db_path |
file path | DuckDB database path. |
refresh_min_interval_seconds |
integer >= 60 |
Global cooldown across all symbols. |
pricing_model |
"cash_pv_bsm_v2" |
Only supported model. |
rate_source |
"fixture", "nyfed_sofr", "manual" |
"manual" reads manual_rate from reference_inputs_path. |
dividend_sources |
keys SPY, QQQ, AAPL |
"fixture", "manual_schedule", or "nasdaq_dividends" (QQQ/AAPL only). |
reference_inputs_path |
file path | Local override file (optional when rate_source != "manual" and reference/dividend_schedules.json exists). |
- Fixture rule: Use
"fixture"rate/dividend sources only withsource_mode: "fixture". - Example live config:
{
"source_mode": "nasdaq",
"db_path": "data/options.duckdb",
"refresh_min_interval_seconds": 60,
"pricing_model": "cash_pv_bsm_v2",
"rate_source": "nyfed_sofr",
"dividend_sources": {"SPY": "manual_schedule", "QQQ": "manual_schedule", "AAPL": "nasdaq_dividends"},
"reference_inputs_path": "reference_inputs.json"
}- Automated baseline:
SPY,QQQ, andAAPLschedules are committed daily in reference/dividend_schedules.json (git pullto update). - Local overrides: Place manual overrides (or
manual_rate) inbackend/reference_inputs.json(git-ignored). - Precedence rules:
- Every non-fixture source requires a schedule reviewed within
0–7days (REVIEW_MAX_AGE_DAYS). - Among fresh reviews (
<= 7d), any schedule with"declared"events beats an"estimated"-only schedule; ties break by newestreviewed_at. - Coverage must span
today .. latest in-scope expiration(<= 30DTE). - An empty
expected_events: []asserts no dividends in that window. amount_status:"declared"or"estimated"(withamount), or"pending_source"(amount: null,"nasdaq_dividends"only).
- Every non-fixture source requires a schedule reviewed within
- Parity cross-check:
backend/analytics.pycompares scheduledpv_dividendsagainst near-ATM put-call parity (±5%strikes) and emitsDIVIDEND_PARITY_DIVERGENCEif they disagree.
Example backend/reference_inputs.json override
{
"input_schema_version": 1,
"manual_rate": null,
"schedules": {
"AAPL": {
"symbol": "AAPL",
"reviewed_at": "2026-01-02T21:00:00Z",
"coverage_start": "2026-01-02",
"coverage_end": "2026-04-02",
"no_other_events_expected": true,
"source_refs": ["my-review"],
"expected_events": [
{
"event_id": "aapl-2026q1",
"ex_date": "2026-02-09",
"payment_date": null,
"amount": "0.26",
"amount_status": "declared",
"source_ref": "apple-ir"
}
]
}
}
}.github/workflows/reference-update.yml runs weekdays at 22:00 UTC (after the US close) and commits only when outputs change:
scripts/update_ratios.py→ reference/conversion_ratios.json: Display-onlySPX/SPYandNDX/QQQratios (ADR-0002).scripts/update_dividends.py→ reference/dividend_schedules.json:SPY(3rd Fri, shifting Thu on Good Friday/Juneteenth),QQQ(following Mon),AAPL(YahooTicker.info['exDividendDate']when already declared ahead of history, else+13 weekswith a7-day pre-ex grace hold) (ADR-0003).- Failure isolation: Bad data preserves the prior entry (per symbol for dividends) so other symbols still update, and fails the workflow so GitHub sends an alert.
- Manual refresh only: Nothing polls or auto-refreshes.
- Cache bypass: Refresh including reference inputs ignores the 1h SOFR cache and 6h dividend cache.
- Retention & warnings: Keeps the latest 20 snapshots per symbol; warnings appear in
SnapshotMetaand panel headers.
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/api/health |
Database connectivity check |
GET |
/api/config |
Enabled symbols, scope, cooldown state |
GET |
/api/dashboard/{symbol} |
Latest saved snapshot (no network fetch) |
POST |
/api/dashboard/{symbol}/refresh |
Fetch, price, and save (?force_reference_refresh=true bypasses reference caches) |
- CI checks:
cd backend ruff check . ruff format --check . ty check pytest --ignore=tests/test_performance.py pip install -r ../scripts/requirements.txt && python ../scripts/daily_heatmap.py --fixture cd ../frontend npm run lint && npm run build && npm test
(CI skips tests/test_performance.py because timings are hardware-dependent.)
- Offline counterfactual reconciliation (stop the backend first so DuckDB isn't locked):
cd backend python reconcile.py --db data/options.duckdb --snapshot-id <uuid> \ --scenario-inputs reference_inputs.scenario.json \ --out exports/<uuid>-pricing-comparison
The scenario file requires both manual_rate and a schedule for the snapshot's symbol. If the baseline fails to reproduce saved IV/gamma/exclusions, reconcile.py exits with BASELINE_REPRODUCTION_FAILED.
- Providers: Implement the Protocols in backend/provider.py and wire them in
build_*inside backend/app.py. - New symbols: Verify both chain and dividend endpoints first (see source contracts), then add to backend/instruments.py and
dividend_sources. - Spot rule: Underlying price must always come from the option-chain payload, never a separate quote endpoint.
- Specs & ADRs: PRD · ADR-0001 · ADR-0002 · ADR-0003 · ADR-0004 · ADR-0005
- Guides: How to read the heatmap
- Data contracts: Nasdaq option chain · Nasdaq dividends · NY Fed SOFR
- Nasdaq (
"nasdaq","nasdaq_dividends"): Unofficial endpoints; no affiliation or license. Review Nasdaq's terms before enabling. - NY Fed SOFR (
"nyfed_sofr"): Public New York Fed rates API. - Yahoo Finance via yfinance (Apache-2.0): Used only by the daily GitHub Action for ratios and dividend history; unofficial and not affiliated with Yahoo (Yahoo terms). Only derived values are committed.
- Repo hygiene: Fixtures, tests, and screenshots use synthetic data. Never commit real market data, databases, credentials, or
exports/.
- Limitations:
- Point-in-time snapshots only (not a live feed or trading signal).
- European BSM approximation (no American early-exercise modeling).
- Open interest does not identify who is long or short.
- SOFR is treated as a flat overnight rate, not a term curve.
- Nasdaq chains lack per-quote timestamps, multiplier fields, and intraday spot timestamps (docs/source-contract.md).
- Projected dividends default to last-paid amounts unless overridden with
"declared"inputs.
- License: MIT for this repository's code; third-party dependencies and market data keep their own licenses.

