Real-time options market gamma exposure analysis for major indices - identify dealer hedging flows and key support/resistance levels
# Clone the repository
git clone https://github.com/pikki622/gex-analytics.git
cd gex-analytics
# Install dependencies with uv
uv sync
# Run gamma analysis for S&P 500
uv run python gammaProfileCommandLine10bps.py SPXAnalyzes options market gamma exposure to reveal:
- 🎯 Gamma flip points - Where dealer hedging behavior reverses
- 📈 Support/Resistance levels - Based on options positioning
- ⚡ Volatility forecasts - Whether dealers amplify or dampen moves
- 💰 Hedging flow estimates - Dollar amounts dealers must trade
- Features
- How It Works
- Installation
- Usage
- Available Tickers
- Output Charts
- Interpretation Guide
- 📚 Terminology Guide
- Development Roadmap
- Contributing
- ✅ 10 Major Indices - SPX, NDX, RUT, VIX, and more
- ✅ Real-time Data - 15-minute delayed quotes from CBOE
- ✅ Two Analysis Modes - 1% moves or precise 10bps moves
- ✅ 5-Panel Visualization - Comprehensive gamma analysis charts
- ✅ ADTV Context - Hedging flows relative to daily volume
- ✅ Batch Processing - Generate reports for all indices at once
Coming Soon (See Roadmap)
- 🔄 Visual hierarchy with risk indicators
- 🔄 Trade setup recommendations
- 🔄 Historical gamma tracking
- 🔄 Cross-index correlation analysis
This tool fetches real-time options data from CBOE (Chicago Board Options Exchange) and calculates the gamma exposure of market makers at different price levels. This helps identify:
- Where market makers need to hedge (buy/sell underlying)
- Potential support and resistance levels
- The "gamma flip" point where hedging behavior changes
-
Data Fetching (lines 32-34)
- Connects to CBOE's delayed quotes API
- Downloads complete options chain for the specified index
- Extracts current spot price
-
Data Processing (lines 46-87)
- Parses option symbols to extract strike prices and expiration dates
- Separates calls and puts
- Merges data into a unified DataFrame
- Converts data types for calculations
-
Gamma Calculations (lines 90-98)
- Calculates spot gamma exposure for each strike
- Formula:
GEX = Unit Gamma × Open Interest × 100 × Spot² × 0.01 - Puts have negative gamma exposure (market makers are short puts)
-
Gamma Profile Generation (lines 138-173)
- Simulates gamma at different spot prices
- Uses Black-Scholes model for theoretical gamma values
- Identifies the "gamma flip" point (zero gamma crossing)
-
Visualization (lines 100-206)
- Generates 4 interactive charts showing different aspects of gamma exposure
Gamma exposure represents the amount of shares market makers must buy or sell to maintain delta neutrality when the underlying price moves 1%.
- Positive Gamma: Market makers dampen volatility (buy dips, sell rallies)
- Negative Gamma: Market makers amplify volatility (sell dips, buy rallies)
- Zero Gamma (Flip Point): Transition between stabilizing and destabilizing hedging flows
The calcGammaEx function (lines 13-25) implements the Black-Scholes gamma formula:
gamma = exp(-q*T) * norm.pdf(d1) / (S * vol * sqrt(T))Where:
S: Spot priceK: Strike pricevol: Implied volatilityT: Time to expirationr: Risk-free rate (set to 0)q: Dividend yield (set to 0)
- Business days are calculated excluding weekends (line 142-143)
- 0DTE options are set to 1/262 year to avoid division by zero
- Monthly options are identified by third Friday detection (lines 27-29, 147-149)
-
Option Greeks Calculator (
calcGammaEx)- Pure Black-Scholes implementation
- Handles edge cases (zero time/volatility)
- Returns dollar gamma exposure
-
Data Parser
- Extracts components from CBOE option symbols
- Format:
INDEX YYMMDD C/P STRIKE - Example:
SPX241108C05500= SPX Nov 8, 2024 Call at 5500
-
Aggregation Engine
- Groups by strike price
- Sums total gamma across all expirations
- Handles "ex-next expiry" calculations
-
Visualization Module
- 4 distinct chart types
- Interactive matplotlib plots
- Color-coded regions (red = negative gamma, green = positive)
The tool works with CBOE-listed index options through their free API. ETF options require a paid subscription.
| Ticker | Description | Current Spot Price |
|---|---|---|
| SPX | S&P 500 Index | ~$6,728 |
| NDX | NASDAQ-100 Index | ~$25,059 |
| DJX | Dow Jones Index (1/100th scale) | ~$469 |
| RUT | Russell 2000 Index | ~$2,432 |
| VIX | CBOE Volatility Index | ~$19 |
| MXEA | MSCI EAFE Index | ~$2,774 |
| MXEF | MSCI Emerging Markets Index | ~$1,381 |
| XSP | Mini-SPX Index (1/10th SPX) | ~$672 |
| XND | Mini-NDX Index (1/100th NDX) | ~$251 |
| MRUT | Mini-Russell 2000 Index (1/10th RUT) | ~$243 |
ETF options (SPY, QQQ, IWM, etc.) return HTTP 403 errors and require a CBOE DataShop subscription ($380-2000+/month).
- Python 3.8 or higher
- uv package manager (recommended) or pip
# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and setup
git clone https://github.com/pikki622/gex-analytics.git
cd gex-analytics
uv sync# Clone repository
git clone https://github.com/pikki622/gex-analytics.git
cd gex-analytics
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install pandas numpy scipy matplotlib requests# Analyze S&P 500 with 10bps precision (recommended)
uv run python gammaProfileCommandLine10bps.py SPX
# Generate comprehensive report for all indices
uv run python generate_all_charts.py
# Test which tickers are available
uv run python test_tickers.py| Script | Description | Use Case |
|---|---|---|
gammaProfileCommandLine10bps.py |
Recommended - 10bps precision with grid layout | Daily analysis |
gammaProfileCommandLine.py |
Original 1% move analysis | Quick checks |
generate_all_charts.py |
Batch process all indices | Full market scan |
test_tickers.py |
Check ticker availability | Troubleshooting |
# Analyze S&P 500 gamma (1% moves)
uv run python gammaProfileCommandLine.py SPX
# Analyze NASDAQ-100 gamma (10bps moves, grid view)
uv run python gammaProfileCommandLine10bps.py NDX
# Test all available tickers
uv run python test_tickers.pyThe tool generates a comprehensive 5-panel analysis (10bps version includes ADTV table):
Example output for S&P 500 showing gamma exposure, open interest distribution, and flip points
The tool generates 5 comprehensive visualizations:
- Bar chart showing net gamma at each strike price
- Helps identify key support/resistance levels
- Positive bars = net long gamma, Negative = net short gamma
- Shows call OI above zero, put OI below zero
- Identifies where most options positions are concentrated
- Large OI strikes often act as "magnets" for price
- Separates call gamma (positive) from put gamma (negative)
- Shows which side dominates at each strike
- Useful for understanding directional hedging flows
- Line chart showing gamma across different spot prices
- Identifies the "gamma flip" point (zero crossing)
- Shows ex-next expiry and ex-monthly expiry profiles
- Red shading = negative gamma zone (volatility amplifying)
- Green shading = positive gamma zone (volatility dampening)
- Shows gamma exposure for different move sizes (1-500bps)
- Contextualizes hedging flows vs 20-day ADTV
- Highlights when flows exceed 10% of daily volume
- Critical for understanding market impact potential
Check out our comprehensive guides:
- Terminology Guide - Plain English explanations of all terms
- FAQ - Quick answers to common questions
- Real-world examples and decision trees
- Trading strategies based on gamma state
- Total Gamma: Net $ exposure market makers must hedge per 1% or 0.1% move
- Gamma Flip: Price where market maker hedging behavior reverses
- Negative Gamma: Below flip point, dealers sell into weakness, buy into strength
- Positive Gamma: Above flip point, dealers buy into weakness, sell into strength
- Large positive gamma = Lower volatility expected (dampening effect)
- Large negative gamma = Higher volatility expected (amplifying effect)
- Gamma flip point often acts as pivot level for intraday price action
- High OI strikes can act as support/resistance due to pinning effects
- Python 3.8+
- pandas, numpy, scipy, matplotlib, requests
- uv package manager (recommended) or pip
Options data is sourced from CBOE's delayed quotes API (15-minute delay). Real-time data requires CBOE subscription.
See IMPLEMENTATION_PLAN.md for the detailed roadmap. Key upcoming features:
- ✅ Documentation improvements
- 🔄 Visual hierarchy with risk indicators
- 🔄 Glossary and terminology guide
- Trade setup recommendations
- Scenario analysis engine
- Risk management guidelines
- Historical gamma tracking
- Enhanced visualizations
- Cross-index correlation analysis
We welcome contributions! Here's how to get started:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (when available)
- Commit with descriptive message (
git commit -m 'Add amazing feature') - Push to your branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please use the PR template and follow the coding standards in IMPLEMENTATION_PLAN.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- CBOE for providing options data API
- The options trading community for gamma exposure concepts
- Contributors and users providing feedback
- GitHub Issues: Report bugs or request features
- Repository: github.com/pikki622/gex-analytics
If you find this tool useful, please ⭐ the repository!
