This is the open-source, self-run client for the Foxchase Trading SPX/NDX 0DTE gamma-exposure dashboard. Your Schwab app credentials and OAuth tokens stay on your computer. The client retrieves the option chain locally, removes every field the calculation does not need, and sends the minimized numeric snapshot to the private Foxchase Trading calculation API.
The GEX calculation and Foxchase Trading Read classifier are intentionally not included in this repository. This client is free to run yourself; a fully hosted version may be offered separately after the required brokerage/data approvals are in place.
Many gamma-exposure dashboards require a recurring subscription. Foxchase Trading GEX provides a free, self-run alternative for technically comfortable traders who are willing to connect and maintain their own approved Schwab developer app.
Subject to the required brokerage and market-data approvals, Foxchase Trading may also offer a premium browser-based version with simplified OAuth, managed hosting, automatic updates, and no local installation.
The EC2 request contains only:
- symbol and underlying spot;
- current 0DTE expiration date;
- option type, strike, open interest, gamma, volatility fallback, and multiplier.
It does not contain your Schwab client ID, client secret, access token, refresh token, account number, order history, positions, quotes, contract symbols, bid/ask data, or personal information. Submitted snapshots are calculated in memory and are not stored. Anonymous active-session presence stores only a one-way digest of a random browser-session ID for 90 seconds.
The displayed count is active browser-session IDs, not unique people. The client creates a random ID and stores it in tab-scoped sessionStorage. Reloading the same tab reuses that ID. Independently opened tabs and separate browser profiles, including incognito contexts, normally get separate IDs; a tab opened with an opener can start with a copy of that tab's sessionStorage, so IDs are not guaranteed to map one-to-one to tabs or people. The client sends a presence heartbeat immediately and every 30 seconds. GEX requests also refresh the same presence record. The API stores only the ID's SHA-256 digest and last-seen time; records expire after 90 seconds by default (configured values have a 30-second minimum). A closed tab can remain in the count until its last record is older than the TTL and a later API request cleans it up. No account, IP address, fingerprint, or persistent user identity is used.
You need a regular Schwab brokerage account and a separate account on the Schwab Developer Portal.
- Register or sign in at the Schwab Developer Portal.
- In your developer profile, request the Individual Developer role if you do not already have it.
- Request access to Trader API - Individual and wait for approval.
- Open the developer dashboard and create an app.
- Select Market Data Production. This dashboard reads option-chain market data and does not place orders, so Accounts and Trading access is not required.
- Use an app name such as
Foxchase Trading GEX Local. - Set the callback URL to exactly
https://127.0.0.1with no trailing slash. - Submit the app and wait until its status is Ready for use. A pending or provisionally approved app will not authenticate.
- Open the approved app's details and copy its Client ID and Client Secret. Never post either value or commit them to Git.
The callback URL in the portal and .env must match exactly, including capitalization, protocol, port, path, and trailing slash.
Python 3.9 or newer is required.
git clone https://github.com/adamk/foxchase-gex.git
cd foxchase-gex
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtInstall Python 3.9 or newer, then use PowerShell from the repository folder:
py -3 -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e .
python run.pyIn Command Prompt, activate with .venv\Scripts\activate.bat. Open
http://127.0.0.1:8765 after the local server starts.
The package installs the cross-process token lock and Windows timezone data
automatically; no manual locking setup is needed.
Start Foxchase GEX:
python run.pyOpen http://127.0.0.1:8765. On first run, the local
dashboard opens the Schwab setup wizard. Copy the Client ID and Client
Secret from your Schwab Developer Portal app details. The redirect URI
defaults to https://127.0.0.1 and must exactly match the callback registered
with Schwab.
Choose Save Schwab credentials. Foxchase GEX saves these credentials on your
computer in ~/.foxchase-gex/schwab_credentials.json, then returns to the setup
page without navigating away. On Linux and macOS, the file and directory use
0600 and 0700 permissions. On Windows, the files inherit the ACL of the
user-profile configuration directory because Windows does not expose equivalent
POSIX mode bits; keep any custom configuration directory under a private user
profile path.
The secret is submitted only to this local app and to Schwab's token endpoint;
it is not returned to the browser after saving and is not sent to Foxchase
Trading. Foxchase GEX also creates a local session-signing secret in the same
private directory when needed.
The setup page displays the remaining steps before you leave it:
- Click Open Schwab Authorization. Schwab opens in a new browser tab, and the Foxchase GEX setup page stays open in the original tab.
- Sign in to Schwab and approve the developer app.
- Schwab redirects to
https://127.0.0.1. The page may fail to load; this is normal for this local callback flow. - Keep the browser open and copy the complete URL from the address bar.
- Return to the still-open Foxchase GEX setup tab and paste the URL into Step 3.
- Click Complete Schwab Connection. The code is exchanged locally through the existing OAuth implementation and is neither displayed again nor logged. After a successful exchange, the dashboard shows Schwab Connected ✓ and the local Schwab authorization status.
By default, python run.py binds to loopback only. Keep it on 127.0.0.1 or
localhost while using the setup wizard; the wizard is disabled for
non-loopback hosts. Credentials and OAuth tokens stay on your computer.
Manual .env setup remains supported for advanced users. Copy the example and
set the values for your own Schwab developer app:
cp .env.example .envSCHWAB_CLIENT_ID=your_client_id
SCHWAB_CLIENT_SECRET=your_client_secret
SCHWAB_REDIRECT_URI=https://127.0.0.1Environment credentials take precedence over the GUI credential file. To use
the existing terminal flow instead, run python -m gex_client.login, open the
printed authorization URL, and paste the full Schwab redirect URL at the hidden
terminal prompt. The token is stored with user-only permissions in
~/.foxchase-gex/schwab_tokens.json by default.
The production-compatible three-file UI source and guarded deployment mapping
are documented in deploy/PRODUCTION_UI.md. The
deployment script requires an exact production UI baseline, creates a
timestamped rollback backup, and never writes root-level /SHA256SUMS.
Set FOXCHASE_GEX_DATA_DIR to the directory where historical snapshots should
be stored. The dashboard automatically shows the historical-session controls once
that directory contains archived sessions. FOXCHASE_GEX_REQUIRED_MOUNT can be
set to a mounted drive root; the collector then refuses to write when that drive
is unavailable, preventing data from falling back to the system disk.
Run the dashboard continuously, then start the headless collector:
export FOXCHASE_GEX_DATA_DIR=/mnt/t7/foxchase-gex/archive
export FOXCHASE_GEX_REQUIRED_MOUNT=/mnt/t7
python -m gex_client.collectorThe default interval is 60 seconds for SPX and NDX from 09:30 through 16:00 ET
on weekdays. Set FOXCHASE_GEX_CAPTURE_SECONDS to a value of 30 or greater to
change it. Each schema-v2 JSONL archive record contains the computed GEX result
and the sanitized causal option-chain input snapshot sent to the private
calculation API, along with request/response timestamps, provenance, and content
hashes. The causal input is minimized; it is still market-data-derived and may
remain subject to Schwab and exchange data terms. The archive does not contain
OAuth tokens, client secrets, account numbers, orders, or positions.
The existing local Historical Session dropdown reads these JSONL sessions directly. Read about the archive contract, read-only verification, local publishing, and recovery in:
docs/HISTORY_ARCHITECTURE.mddocs/ARCHIVE_SCHEMA.mddocs/HISTORICAL_PUBLISHING.mddocs/ARCHIVE_RECOVERY.md
The SPX and NDX charts also offer a Live Replay slider for the current Eastern session. The headless collector above is the ingestion source: each completed schema-v2 archive record becomes one selectable timestamp. Choose an earlier point to see that recorded GEX result; choose Live to return to the newest recorded capture. Gaps are not filled, and a delayed newest capture is marked stale. The separate Historical Session dropdown remains available for older days.
Live Replay uses the same FOXCHASE_GEX_DATA_DIR archive and the existing local
dashboard access controls. Its read-only timeline and snapshot endpoints are
/api/live-replay/SPX/{timeline,snapshot} and the equivalent NDX paths. The
snapshot response contains computed GEX output and capture provenance, not the
archived causal option-chain input. No market-data files are distributed with
this repository. Keep your archive and OAuth state outside Git; review the
applicable market-data terms before sharing recorded snapshots.
Each successful collector snapshot also appends a shadow-only structural audit
under FOXCHASE_GEX_DATA_DIR/audit/SPX/YYYY-MM-DD.jsonl. The record preserves
net gamma, the modeled zero-gamma flip, call/put walls and strength, imbalance,
wall migration, and provisional bull-put, call-credit, and iron-condor
allow/block labels. These labels are research observations only: they never
connect to a broker and cannot place, resize, or close a trade. Raw features are
kept alongside every label so thresholds can be re-scored later without
recollecting the market data.
Set FOXCHASE_GEX_FORWARD_AUDIT=0 to disable the derived audit while retaining
the ordinary GEX snapshot archive.
The collector includes the production-compatible foxchase_shadow_gex_v2
audit module. An optional FOXCHASE_ALGO_STATE_PATH supplies same-day research
context; without it, context-dependent observations remain WATCH. Optional
dashboard telemetry requires an explicitly configured URL and token. Keep those
values and all state files outside Git. Telemetry is best-effort and is not a
broker/order interface.
The units in deploy/ are reference examples for a Pi with an external archive
mount. Review the user, paths, mount dependency and bind address before installing;
the dashboard example binds to 0.0.0.0, unlike the loopback default. They do not
contain the private production identity overrides, credentials or trading units.
pip install pytest
pytestThis project is research software, not investment advice. It does not place trades. You are responsible for complying with the terms and market-data rights attached to your brokerage/developer account. Do not commit .env or token files; both are ignored by Git.
Schwab interactive authorization lasts seven days. Automatic access-token refreshes never extend that deadline. The local dashboard shows the exact UTC deadline and a live countdown, with warnings starting at 72 hours, increasing at 24 hours and requiring reauthorization at expiration. You may reauthorize earlier.
Select Reauthorize Schwab to open the existing local /setup page. Saved
Client ID and Client Secret stay private on your computer and are reused; do not
enter them again unless missing or rejected by Schwab. Open Schwab in the new tab,
approve access, then copy the complete redirected URL into the setup completion
form. A connection error at the callback address is expected. Keep that URL private.
Success requires both token exchange and an authenticated Schwab request. If the
exchange result is ambiguous, do not resubmit it automatically. These instructions
apply only to this local installation, not another machine's collector.