I trade options on the NIFTY 50. Not casually — I wanted to understand the math, test strategies against real data, and make decisions with evidence instead of gut feeling. So I built an entire toolkit from scratch.
Nifty Strats is a Python-based options analysis system: fetch market data, run 30+ trading strategies, visualise option chains like Sensibull, and calculate P&L with Black-Scholes pricing. It’s the tool I wish existed when I started trading.
What it does
- OHLCV data fetching — pulls NIFTY 50 candle data via yfinance with configurable periods and intervals. Outputs CSV and interactive Plotly charts.
- NSE option chain scraping — downloads full snapshots of all CE/PE rows across all expiries directly from NSE. Works for both index and equity options.
- 30+ signal generators — MA crossovers, momentum, mean reversion, RSI+Bollinger, stochastic breakouts, VWAP reversals, supertrend, Keltner squeezes, Donchian breakouts, support/resistance, harmonic patterns, and more. Each strategy implements a common ABC.
- Weighted strategy combos — run multiple strategies simultaneously with custom weights. Get a combined signal with performance metrics: return, max drawdown, win rate, per-strategy stats.
- Signal-to-contract mapping — takes a strategy signal (BUY/SELL) and maps it to specific option contracts. Picks the right expiry, calculates premium outlay, suggests alternatives.
- Sensibull-style visualiser — dark-theme option chain viewer with ITM/OTM colouring, OI bars, IV, breakeven, time value, max pain, and put-call ratio.
- Options P&L calculator — 10 strategy presets (Long Call, Bull Call Spread, Iron Condor, Butterfly), up to 4 custom legs, multi-date payoff charts, P&L heatmaps, and full Greeks.
- LSTM direction classifier — predicts next-day NIFTY direction using technical indicators plus context features (Bank Nifty, USD/INR, India VIX). Walk-forward validated.
- NSE 200 swing screener — stock-level swing signals across the full NSE 200 universe with PnL-based walk-forward evaluation.
Technical decisions
The strategy system uses an abstract base class — every strategy implements the same interface, which makes combining them trivial. You can run all 30+ at once with weighted voting, or cherry-pick three and assign your own weights.
The option chain visualiser uses Plotly for interactive charts. I studied Sensibull’s UI extensively and replicated the most useful parts: ITM/OTM colour coding, open interest bars, implied volatility columns, and max pain calculation. The dark theme isn’t aesthetic — it’s because you stare at charts at 9:15 AM and bright white hurts.
The P&L calculator uses Black-Scholes with real NSE data. The multi-date payoff is the killer feature — you see how your position decays over time, not just at expiry. Most free calculators only show the expiry curve.
What I learned
Backtesting is easy. Trading is hard. The toolkit helped me understand why most strategies fail in production — slippage, timing, psychology, and the gap between signal and execution. The code doesn’t hesitate; humans do.
NSE’s API is hostile to automation. Rate limiting, session blocks, and anti-bot headers mean you need patience and smart caching. The scraper handles all of this gracefully now, but it took iterations.