A comprehensive Python platform for NSE options traders to analyze, calculate, and visualize multi-leg options strategies with real-time P&L tracking across multiple brokers (ICICI Direct, Nuvama).
- Strategy Analysis: Calculates max profit, max loss, and breakeven points for 13 predefined options strategies
- Greeks Calculation: Computes Delta, Gamma, Theta, Vega, and IV for portfolio risk analysis
- Profitability Scanning: Automatically scans entire NSE F&O universe for profitable opportunities
- Multi-Broker Integration: Consolidates positions and P&L across ICICI Direct and Nuvama Wealth
- Real-time Dashboard: Visualize strategies and P&L using Metabase (open-source BI tool)
- Excel Export: Generates sorted, formatted Excel sheets with all strategy metrics
- Risk Management: Monitor margin, set P&L alerts, track order execution across brokers
| Strategy | Type | Risk | Reward | Best For |
|---|---|---|---|---|
| Long Call Condor | Debit | Limited | Limited | Neutral, low vol |
| Long Iron Butterfly | Debit | Limited | Limited | Range-bound |
| Long Put Condor | Debit | Limited | Limited | Bearish, low vol |
| Short Call Butterfly | Credit | Limited | Limited | Sideways |
| Short Call Condor | Credit | Limited | Limited | Bullish, high vol |
| Short Guts | Credit | Unlimited | Limited | High volatility |
| Short Iron Butterfly | Credit | Limited | Limited | Tight range |
| Short Put Butterfly | Credit | Limited | Limited | Support holding |
| Short Put Condor | Credit | Limited | Limited | Bullish, narrow |
| Short Straddle | Credit | Unlimited | Limited | Neutral, low vol |
| Short Strangle | Credit | Unlimited | Limited | Neutral, wide |
| Naked Call | Credit | Unlimited | Limited | Bearish |
| Naked Put | Credit | Unlimited | Limited | Bullish |
All strategies are exported to Excel with complete P&L analysis:
Consolidated P&L Dashboard - Total profit/loss across all brokers:
Strategy Performance Dashboard - Individual stock strategy analysis:
Stock Strategy P&L Charts:
Time-Series P&L Analysis:
MWPL (Ban List) Monitoring:
Option Price Charts:
Margin Tracking Dashboard:
Orders Management Dashboard:
Profitable Strategies Scan Results:
- Python 3.7+
- pip / conda
- Optional: Java (for Metabase dashboards)
# Clone the repository
git clone https://github.com/mirajgodha/options.git
cd options
# Create virtual environment
python -m venv venv
source venv/bin/activate # Mac/Linux
# OR
venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Configure settings
# Edit helper/constants.py with your preferences
# Run analysis
python main.pyfrom strategy.calculator import StrategyCalculator
from data.nse_fetcher import NSEDataFetcher
# Fetch option chain data
fetcher = NSEDataFetcher()
option_chain = fetcher.fetch_option_chain('RELIANCE', expiry_date='2025-01-30')
# Calculate SHORT_STRANGLE strategy
calc = StrategyCalculator('RELIANCE', option_chain, 'SHORT_STRANGLE')
strategy = calc.calculate(short_put_strike=2700, short_call_strike=3100, quantity=1)
# View results
print(f"Max Profit: βΉ{strategy.max_profit}")
print(f"Max Loss: βΉ{strategy.max_loss}")
print(f"Theta (Daily Decay): βΉ{strategy.greeks['theta']}")
print(f"Breakeven: {strategy.breakeven_points}")from scanner.profitability_scanner import ProfitabilityScanner
scanner = ProfitabilityScanner(
max_loss_threshold=2000,
profit_probability_threshold=0.60
)
results = scanner.scan_all_strategies(
strategies=['SHORT_STRANGLE', 'SHORT_STRADDLE'],
strike_difference=100
)
scanner.export_to_excel(results, 'profitable_strategies.xlsx')
scanner.export_to_database(results)from brokers.icici_direct import ICICIDirectConnector
from brokers.nuvama import NuvamaBrokerConnector
# Connect to ICICI Direct
icici = ICICIDirectConnector(username='your_id', password='your_pwd')
icici.authenticate()
icici_positions = icici.get_positions()
# Connect to Nuvama
nuvama = NuvamaBrokerConnector(client_id='your_client_id', password='your_pwd')
nuvama.authenticate()
nuvama_positions = nuvama.get_positions()
# Consolidated view
total_pnl = sum(p['pnl'] for p in (icici_positions + nuvama_positions))
print(f"Total P&L across all brokers: βΉ{total_pnl:,.2f}")options/
βββ README.md # This file
βββ requirements.txt # Python dependencies
βββ helper/
β βββ constants.py # Configuration settings
βββ strategy/ # Core calculation engine
β βββ calculator.py # Strategy calculator
β βββ definitions.py # Strategy definitions
β βββ greeks.py # Greeks calculation
βββ data/ # Data fetching
β βββ nse_fetcher.py # NSE option chain data
β βββ historical_data.py # Historical prices
βββ brokers/ # Broker integrations
β βββ icici_direct.py # ICICI Direct connector
β βββ nuvama.py # Nuvama Wealth connector
β βββ broker_base.py # Abstract interface
βββ scanner/ # Scanning engine
β βββ profitability_scanner.py # Strategy scanning
β βββ filters.py # Filtering logic
βββ output/ # Export functionality
β βββ excel_writer.py # Excel export
β βββ sql_writer.py # Database export
β βββ metabase_config.py # Metabase setup
βββ dashboard/ # Metabase configs
βββ metabase/ # Metabase JAR and configs
βββ main.py # Entry point
βββ docs/ # π Documentation
βββ START_HERE.md
βββ QUICK_NUVAMA_SETUP.md
βββ installation_guide.md
βββ nuvama_integration_guide.md
βββ multi_broker_integration_guide.md
βββ comprehensive_docs_with_screenshots.md
βββ api_documentation.md
βββ DOCUMENTATION_INDEX.md
Edit helper/constants.py:
# Market settings
TEST_RUN = False # Test outside market hours
MARKET_OPEN_HOUR = 9
MARKET_CLOSE_HOUR = 15
# Strategy configuration
STRIKE_DIFFERENCE = 100 # For strangle/straddle
MAX_LOSS_THRESHOLD = 1000 # Scanning filter
# Database
DB_TYPE = 'sqlite'
DB_CONNECTION_STRING = 'sqlite:///options_data.db'
# Broker Configuration
ENABLE_BROKER_SYNC = True
# ICICI Direct
ICICI_DIRECT_ENABLED = True
ICICI_USERNAME = 'your_username'
ICICI_PASSWORD = 'your_password'
# Nuvama Wealth
NUVAMA_ENABLED = True
NUVAMA_CLIENT_ID = 'your_client_id' # Get from profile
NUVAMA_PASSWORD = 'your_password'
# Output
WRITE_TO_EXCEL = True
WRITE_TO_SQL = True
EXCEL_OUTPUT_PATH = './output/'| Broker | Status | API Charges | F&O Support | Documentation |
|---|---|---|---|---|
| ICICI Direct | β Production Ready | No | Yes | Setup |
| Nuvama Wealth | β Production Ready | No | Yes | Guide |
| Multi-Broker | β Production Ready | No | Yes | Guide |
| Zerodha | π Roadmap | No | Yes | - |
| 5Paisa | π Roadmap | No | Yes | - |
from brokers.icici_direct import ICICIDirectConnector
connector = ICICIDirectConnector(username='your_id', password='your_pwd')
connector.authenticate()
positions = connector.get_positions() # Current positions
margin = connector.get_margin_used() # Margin status
orders = connector.get_orders(status='OPEN') # Open orders
mwpl = connector.check_mwpl() # Ban list alertsfrom brokers.nuvama import NuvamaBrokerConnector
# Get Client ID from https://www.nuvamawealth.com/login β Profile
connector = NuvamaBrokerConnector(client_id='your_client_id', password='your_pwd')
connector.authenticate()
positions = connector.get_positions() # Current positions
margin = connector.get_margin_used() # Margin status
orders = connector.get_orders(status='OPEN') # Open orders
mwpl = connector.check_mwpl() # MWPL statusfrom brokers.icici_direct import ICICIDirectConnector
from brokers.nuvama import NuvamaBrokerConnector
# Connect to both brokers
icici = ICICIDirectConnector(username='id', password='pwd')
nuvama = NuvamaBrokerConnector(client_id='id', password='pwd')
icici.authenticate()
nuvama.authenticate()
# Consolidated metrics
icici_pnl = sum(p['pnl'] for p in icici.get_positions())
nuvama_pnl = sum(p['pnl'] for p in nuvama.get_positions())
print(f"ICICI Direct: βΉ{icici_pnl:,.2f}")
print(f"Nuvama Wealth: βΉ{nuvama_pnl:,.2f}")
print(f"Total: βΉ{icici_pnl + nuvama_pnl:,.2f}")Quick Start (10 minutes):
- QUICK_NUVAMA_SETUP.md - Get started with Nuvama immediately
Complete Integration Guides (30-40 minutes each):
- Nuvama Integration Guide - Complete setup, 12+ working examples, troubleshooting, advanced features
- Multi-Broker Integration Guide - Use ICICI Direct + Nuvama together, consolidated dashboard, real-time monitoring script
General Setup & Reference:
- Installation Guide - All platforms (Windows/Mac/Linux/Docker), 10 troubleshooting solutions
- API Reference - 50+ working code examples
Complete Feature Documentation:
- Comprehensive Guide - All features, 13 strategies, 13 integrated screenshots
β
No API charges - Completely free integration
β
βΉ20/lot options - Competitive options brokerage
β
Deep OTM trading - Trade far out-of-money options in NRML mode
β
Discounted exchange charges - ~βΉ3,500/Cr vs standard rates
β
Online margin pledge - Enhance margin instantly
β
SEBI regulated - Safe and trustworthy broker
Quick Links:
- Account Opening: https://www.nuvamawealth.com/demat-account
- Login Portal: https://www.nuvamawealth.com/login
- API Documentation: https://www.nuvamawealth.com/api-connect/
- Support: 1800-102-3335 | [email protected]
To add support for Zerodha, 5Paisa, or other brokers, see Multi-Broker Guide - Adding New Brokers section.
Implement the BrokerInterface abstract class:
authenticate()get_positions()get_margin_used()get_orders()check_mwpl()place_order()(optional)
# Download Metabase
cd metabase/
wget https://downloads.metabase.com/v0.46.6/metabase.jar
# Start Metabase
java -jar metabase.jar
# Access at http://localhost:3000Available Dashboards:
- Consolidated P&L across all brokers
- Strategy-wise P&L breakdown
- Real-time margin tracking
- Order execution analysis
- Greeks heatmaps
- MWPL monitoring
- Multi-broker position tracking
Each strategy generates a separate tab with:
- Symbol, premium, max profit/loss
- Breakeven points
- Greeks (Delta, Gamma, Theta, Vega, IV)
- P&L at different price levels
- Available strike prices
Example Output:
RELIANCE | Premium: βΉ850 | Max Profit: βΉ850 | Max Loss: βΉ2150
Theta: βΉ45.3/day | Delta: -0.15 | IV: 18.5%
Breakeven: 2650, 3050
# Scan multiple strategies across all NSE F&O stocks
scanner.scan_multiple(
strategies=['SHORT_STRANGLE', 'NAKED_PUT', 'SHORT_STRADDLE'],
strike_differences={'SHORT_STRANGLE': 150, 'NAKED_PUT': 100}
)# Real-time P&L alerts
monitor = PositionMonitor()
monitor.add_profit_trigger(strategy_id=123, profit_target=5000)
monitor.add_loss_trigger(strategy_id=123, loss_limit=2000)
monitor.start()# Rebalance portfolio to target Greeks
rebalancer.suggest_rebalance(
target_delta=-0.2,
target_vega=0
)# Historical analysis of strategy returns
backtest = StrategyBacktester('SHORT_STRANGLE', 'RELIANCE',
start_date='2024-01-01', end_date='2024-12-31')
results = backtest.run(strike_difference=100, profit_target=0.30)
print(f"Win Rate: {results['win_rate']:.2%}")- Delta: Directional sensitivity (range: -1 to +1)
- Gamma: Rate of delta change (positive for long options)
- Theta: Daily time decay (positive for short options)
- Vega: Volatility sensitivity (per 1% IV change)
- IV: Implied Volatility (market's volatility expectations)
Complete documentation is available in the /docs folder. Start here based on your needs:
- START_HERE.md (5 min) - Overview and what to do next
- QUICK_NUVAMA_SETUP.md (10 min) - Get started with Nuvama in 10 minutes
- Installation Guide (15 min) - Complete setup for your platform
- Comprehensive Guide - Complete documentation with all 13 strategies, features, and 13 integrated screenshots
- API Reference - Complete API documentation with 50+ working code examples
- Multi-Broker Guide - Integration patterns, 9+ examples
- Nuvama Integration Guide - Complete Nuvama setup, 12+ examples, advanced features
- Multi-Broker Integration Guide - Use multiple brokers with unified interface
- Documentation Index - Complete index of all documentation files
| Document | Time | Best For |
|---|---|---|
| START_HERE.md | 5 min | Everyone - start here |
| QUICK_NUVAMA_SETUP.md | 10 min | Nuvama quick start |
| Installation Guide | 15 min | New users |
| Comprehensive Guide | 60 min | Learning all features |
| API Reference | 20 min | Developers |
| Nuvama Integration | 30 min | Nuvama users |
| Multi-Broker Guide | 30 min | Multi-broker setup |
| Documentation Index | 10 min | Finding things |
NSE data not fetching?
- Check internet connectivity
- Verify TEST_RUN flag during market hours
- See Installation Guide - Common Issues
ICICI Direct auth failing?
- Ensure 2FA is disabled for API access
- Verify username/password in config
- See Installation Guide - Common Issues
Nuvama auth failing?
- Verify Client ID is correct (6-8 digits from profile)
- Check password
- See Nuvama Guide - Troubleshooting
Metabase not loading?
- Check if Java is installed:
java -version - Verify Metabase is running:
curl http://localhost:3000
Greeks returning NaN?
- Ensure time to expiry > 0
- Verify IV > 0
- See API Reference - Greeks
Need more help?
- See Installation Guide for 10 common issues & solutions
- Check Documentation Index for complete file navigation
We welcome contributions! Please:
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open Pull Request
pip install flake8
flake8 options/ --max-line-length=100pip install pytest
pytest tests/ -vpandas>=1.3.0
numpy>=1.21.0
openpyxl>=3.6.0
requests>=2.26.0
beautifulsoup4>=4.9.3
lxml>=4.6.3
sqlalchemy>=1.4.0
py_vollib>=0.1.0
scipy>=1.7.0
matplotlib>=3.4.0
This tool is for educational and research purposes. Options trading involves substantial risk of loss. Always:
- β Understand strategies before trading
- β Use proper risk management
- β Paper trade before live trading
- β Consult financial advisors
- β Start with small positions
Past performance does not guarantee future results.
MIT License - See LICENSE file for details
- GitHub Issues: GitHub Issues
- GitHub Discussions: GitHub Discussions
- ICICI Direct Support: 9650200000
- Nuvama Support: 1800-102-3335
- Documentation: See
/docsfolder for comprehensive guides
- Additional broker integrations (Zerodha, 5Paisa, ICICI Securities)
- ML-based strategy recommendations
- Options spreads optimizer
- Real-time SMS/Email alerts
- Mobile app for monitoring
- Portfolio optimization module
- Advanced Greeks visualizations
- Options chain screener
Built by options traders, for options traders. Inspired by professional tools like SensiBull and QuantsApp, but open-source and free.
- GitHub: @mirajgodha
- Contributions welcome!
β If you find this useful, please star the repository!
Last Updated: Jan 2025
Version: 1.0.0
Python: 3.7+









