Greek-Based Momentum Indicators for Options Trading
GammaGEX is a sophisticated Python application that analyzes option chain data to identify stock momentum using advanced Greek-based indicators. Built specifically for Indian markets, it integrates seamlessly with OpenAlgo and Upstox to provide real-time momentum analysis.
-
Net Gamma Exposure (GEX) Analysis
- Identifies market maker hedging behavior
- Detects high/low momentum regimes
- Finds critical "zero gamma" levels
-
Delta-Weighted Volume Flow
- Tracks institutional positioning
- Identifies directional option flow
- Confirms momentum trends
-
Gamma Squeeze Detection
- Identifies squeeze setups in real-time
- Predicts explosive momentum moves
- Monitors call walls and dealer positioning
-
Vanna & Charm Analysis
- Predicts momentum changes from volatility shifts
- Analyzes delta decay patterns
- Second-order Greek momentum prediction
-
IV Skew Momentum
- Tracks fear/complacency in options
- Identifies skew-based reversals
- Monitors put-call IV differentials
-
Composite Momentum Score
- Combines all indicators into single score (0-100)
- Weighted scoring system
- High-confidence signal generation
- Python 3.10+
- OpenAlgo instance running (http://127.0.0.1:5000)
- Upstox broker account connected to OpenAlgo
- OpenAlgo API key
# Clone the repository
git clone https://github.com/aakash-code/GammaGEX.git
cd GammaGEX
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Setup configuration
cp .env.example .env
# Edit .env and add your OpenAlgo API keyEdit .env file:
# OpenAlgo Connection
OPENALGO_HOST=http://127.0.0.1:5000
OPENALGO_API_KEY=your_app_api_key_here
# Broker Configuration
BROKER=upstox
# Database
DATABASE_URL=sqlite:///data/gammagex.db
# Logging
LOG_LEVEL=INFOpython scripts/setup_db.py# Monitor NIFTY
python scripts/monitor.py --symbol NIFTY --expiry current_week
# Monitor BANKNIFTY
python scripts/monitor.py --symbol BANKNIFTY --interval 30
# Monitor specific expiry
python scripts/monitor.py --symbol RELIANCE --expiry 17-JUL-25GammaGEX calculates a composite momentum score (0-100) using weighted contributions from multiple Greek-based indicators:
Momentum Score =
(0.30 ร GEX Signal) +
(0.25 ร Delta Flow Signal) +
(0.20 ร Gamma Squeeze Signal) +
(0.15 ร Vanna Signal) +
(0.10 ร IV Skew Signal)
Interpretation:
- Score > 60: Bullish momentum
- Score 40-60: Neutral/Range-bound
- Score < 40: Bearish momentum
What it measures: Aggregate dealer gamma positions that dictate hedging behavior.
How it works:
For each strike:
Call Gamma Exposure = Call OI ร Call Gamma ร 100 ร Spot
Put Gamma Exposure = Put OI ร Put Gamma ร 100 ร Spot
Net Gamma = Call GEX - Put GEX
Total GEX = Sum of all strikes
Signals:
- Positive GEX: Dealers dampen moves โ Low momentum, range-bound
- Negative GEX: Dealers amplify moves โ High momentum, breakout potential
- Below Zero Gamma Level: Explosive momentum expected
What it measures: Directional option positioning weighted by delta.
How it works:
Bullish Flow = (Call Buy Volume ร Delta)
Bearish Flow = (Put Buy Volume ร Delta)
Net Delta Flow = Bullish - Bearish
Signals:
- Sustained positive flow โ Institutional bullish positioning
- Sustained negative flow โ Institutional bearish positioning
- Flow MA crossovers โ Momentum shifts
What it measures: Conditions that force dealers to buy/sell, creating self-reinforcing moves.
Conditions monitored:
- High call OI above current price
- Rising call gamma
- Low put/call ratio (delta-adjusted)
- Price approaching high-OI strikes
Squeeze Score Components:
- Call OI concentration (30% weight)
- Gamma trend (30% weight)
- PCR delta-adjusted (20% weight)
- Distance to max OI strike (20% weight)
What they measure:
- Vanna: How delta changes with volatility (โDelta/โIV)
- Charm: How delta decays with time (โDelta/โTime)
Signals:
- Rising IV + Positive Vanna โ Delta increasing โ Momentum building
- High Charm โ Delta decay โ Momentum fading
What it measures: Put-Call implied volatility differential.
Formula:
IV Skew = (ATM Put IV - ATM Call IV) / Average IV
Signals:
- Steepening skew โ Fear building โ Potential downward momentum
- Flattening skew โ Complacency โ Potential upward momentum
GammaGEX/
โโโ src/
โ โโโ connectors/ # OpenAlgo API & WebSocket clients
โ โโโ models/ # Data models (Pydantic)
โ โโโ calculators/ # Greek calculators & indicators
โ โโโ storage/ # Database models & repositories
โ โโโ services/ # Business logic orchestration
โ โโโ config.py # Configuration management
โโโ scripts/
โ โโโ setup_db.py # Database initialization
โ โโโ monitor.py # Real-time monitoring CLI
โโโ config/
โ โโโ config.yaml # Application config
โ โโโ symbols.yaml # Symbols to track
โโโ data/ # SQLite database
โโโ logs/ # Application logs
โโโโโโโโโโโโโโโโโโโ
โ Upstox Broker โ
โ (Live Data) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ OpenAlgo API โ
โ (Middleware) โ
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ GammaGEX Engine โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Option Chain Fetcher โ โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ โ
โ โ Greek Calculators โ โ
โ โ โข GEX โ โ
โ โ โข Delta Flow โ โ
โ โ โข Gamma Squeeze โ โ
โ โ โข Vanna/Charm โ โ
โ โ โข IV Skew โ โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ โ
โ โ Momentum Scoring Engine โ โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ โ
โ โ Signal Generator โ โ
โ โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ โ
โ โ Database Storage โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ CLI Monitor โ
โ Dashboard โ
โโโโโโโโโโโโโโโโโโโ
symbols:
- name: NIFTY
exchange: NSE
type: INDEX
track_options: true
lot_size: 75
- name: BANKNIFTY
exchange: NSE
type: INDEX
track_options: true
lot_size: 30
# Default expiry to track
default_expiry: "current_week"
# Strike selection
strike_selection: "atm_range"
atm_range:
above: 10 # Strikes above ATM
below: 10 # Strikes below ATM
# Alert thresholds
alerts:
momentum_score_high: 75
momentum_score_low: 25
gamma_squeeze_threshold: 70
gex_regime_change: trueCustomize indicator weights in code or config:
custom_weights = {
'gex': 0.35, # Increase GEX importance
'delta_flow': 0.30,
'gamma_squeeze': 0.20,
'vanna_charm': 0.10,
'iv_skew': 0.05,
}
calculator = MomentumScoreCalculator(custom_weights=custom_weights)# Basic monitoring
python scripts/monitor.py --symbol NIFTY
# Custom update interval (30 seconds)
python scripts/monitor.py --symbol BANKNIFTY --interval 30
# Specific expiry
python scripts/monitor.py --symbol RELIANCE --expiry 17-JUL-25
# Different exchange
python scripts/monitor.py --symbol TCS --exchange NSEfrom gammagex import GammaGEX
from connectors.openalgo_client import OpenAlgoClient
from calculators.momentum_score import MomentumScoreCalculator
# Initialize client
client = OpenAlgoClient(host="http://127.0.0.1:5000", api_key="your_key")
# Fetch option chain
chain = client.get_option_chain("NIFTY", "17-JUL-25")
# Calculate momentum
calculator = MomentumScoreCalculator()
momentum = calculator.calculate(chain)
print(f"Momentum Score: {momentum.score:.2f}")
print(f"Direction: {momentum.direction.value}")
print(f"Interpretation: {momentum.interpretation}")
# Get high-priority signals
signals = momentum.get_high_priority_signals(min_priority=7)
for signal in signals:
print(f"{signal.signal_type.value}: {signal.description}")โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ GammaGEX - Real-time Momentum Monitor โ
โ Symbol: NIFTY | Expiry: 17-JUL-25 | Spot: โน24,850 | 14:35:22 โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโ Momentum Score โโโโโโโโโโโโโโโโโโฎ โญโโโ Component Scores โโโโโโโโโฎ
โ โ โ Component Score Bar โ
โ ๐ BULLISH MOMENTUM โ โ GEX 72.3 โโโโ โ
โ โ โ Delta Flow 68.5 โโโ โ
โ Score: 71.5/100 โ โ Gamma Squeeze 78.2 โโโโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ โ Vanna Charm 55.1 โโโ โ
โ โ โ IV Skew 48.3 โโ โ
โ Strength: 0.43 โ โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โ Confidence: 0.78 โ
โ โ
โ Primary driver: gamma_squeeze โ
โ GEX Regime: Negative GEX - โ
โ market makers amplify moves โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โญโโโ Active Signals โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ ๐ข [gamma_squeeze] High squeeze risk at 25,000 strike โ
โ ๐ข [negative_gex] High momentum expected below zero gamma โ
โ ๐ข [delta_flow] Bullish institutional flow detected โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
GammaGEX stores all calculations for historical analysis:
- option_chains: Option chain snapshots with Greeks
- spot_prices: Underlying price history
- momentum_indicators: Calculated momentum metrics
- signals: Generated trading signals
- alerts: System alerts
- backtest_results: Backtesting performance
GammaGEX requires a running OpenAlgo instance with Upstox connectivity.
- Install OpenAlgo: https://docs.openalgo.in/
- Connect Upstox broker
- Generate API key
- Add API key to GammaGEX
.envfile
- OptionSymbol API: Fetch option contracts
- OptionGreeks API: Get Greeks (delta, gamma, vega, theta, rho, IV)
- Quotes API: Real-time prices and OI
- Expiry API: Available expiry dates
- WebSocket: Real-time streaming (future feature)
# Run unit tests
pytest tests/
# Run with coverage
pytest --cov=src tests/
# Run specific test file
pytest tests/test_calculators/test_gex.py- Core Greek calculators
- Momentum scoring engine
- Real-time CLI monitor
- Database storage
- WebSocket real-time streaming
- Web dashboard (Streamlit/Dash)
- Backtesting engine
- REST API for external integration
- Multi-symbol monitoring
- Alert notifications (Telegram, Email)
- Advanced charting
- Machine learning momentum prediction
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
This software is for educational and research purposes only.
- Not financial advice
- Use at your own risk
- Past performance does not guarantee future results
- Always do your own research before trading
- The authors assume no liability for any trading losses
For questions, suggestions, or support:
- GitHub Issues: https://github.com/aakash-code/GammaGEX/issues
- Email: support@gammagex.com
- OpenAlgo team for the excellent open-source trading platform
- Upstox for broker API
- Options trading community for inspiration
Built with โค๏ธ for the Indian options trading community
GammaGEX - Because Greeks Know Best!