A fully automated trading and data analysis system built with Python, featuring modular architecture, real-time data processing, and automated strategy execution for the Indian stock market through Zerodha Kite API.
This project implements a distributed, modular architecture with the following key components:
- Data Collection Module: Real-time market data ingestion and storage
- Trading Strategy Module: Automated trading logic and execution
- Login Module: Automated authentication and session management
- Order Management Module: Order placement and position tracking
- Configuration Module: Centralized configuration management
- Data Analysis Module: Historical data analysis and reporting
- Fully Automated Trading: Hands-off operation with scheduled execution
- Real-time Data Processing: Live market data collection and analysis
- Modular Design: Independent, scalable components for easy maintenance
- Redis Pub/Sub: Decoupled communication between modules
- Cron Job Integration: Scheduled automated tasks and monitoring
- Process Management: Robust monitoring and recovery mechanisms
- Historical Analysis: Comprehensive data analytics and reporting
zerodha/
├── ConfigModule/ # Configuration management
│ ├── config.json # Main configuration file
│ └── config_loader.py # Configuration loading utilities
├── DataModule/ # Real-time data collection
│ ├── data_collection.py # Market data ingestion
│ └── get_instruments.py # Instrument data fetching
├── LoginModule/ # Authentication management
│ └── kite_login.py # Automated login handling
├── OrderModule/ # Order management
│ └── place_order.py # Order placement logic
├── Scripts/ # Trading strategies
│ └── 01_nifty50_half_hour_buy_sell_strategy.py
├── DataAnalysis/ # Analytics and reporting
│ ├── 01_strike_price_graph.py
│ └── 02_5min_candle.py
├── ShellScripts/ # Automation scripts
│ ├── manage_processes.sh
│ ├── data_collection.sh
│ └── daily_login.sh
├── Data/ # Historical data storage
└── Log/ # Application logs
- Python 3.12: Core programming language
- KiteConnect API: Zerodha trading platform integration
- Redis: Real-time message broker for pub/sub communication
- Pandas: Data analysis and manipulation
- Shell Scripting: Process automation and monitoring
- Cron Jobs: Scheduled task execution
- JSON: Configuration and data storage
- Python 3.12+
- Redis server
- Zerodha Kite trading account with API access
- Clone the repository:
git clone https://github.com/Mayank-8127/zerodha.git
cd zerodha- Install dependencies:
pip install -r requirements.txt- Start Redis server:
redis-server-
Configure the application:
- Update
ConfigModule/config.jsonwith your Zerodha API credentials - Set correct file paths for your environment
- Update
-
Set up cron jobs (optional):
# Add to crontab for automated execution
crontab -e- Start data collection:
python3 -m DataModule.data_collection- Run trading strategy:
python3 -m Scripts.01_nifty50_half_hour_buy_sell_strategy- Monitor processes:
./ShellScripts/manage_processes.shThe system supports fully automated operation through shell scripts and cron jobs:
- Daily login automation:
./ShellScripts/daily_login.sh - Data collection:
./ShellScripts/data_collection.sh - Process monitoring:
./ShellScripts/manage_processes.sh
- Authentication: Automated login through Zerodha Kite API
- Data Ingestion: Real-time market data collection via WebSocket
- Message Broker: Redis pub/sub for inter-module communication
- Strategy Execution: Automated trading decisions based on market data
- Order Management: Automatic order placement and position tracking
- Data Storage: Historical data archival and analysis
- Real-time market data ingestion using KiteTicker
- Redis pub/sub for broadcasting tick data
- CSV storage for historical analysis
- Support for multiple instruments and indices
- Nifty 50 options trading strategy
- Real-time price monitoring via Redis
- Automated buy/sell signal generation
- Position management and risk controls
- Centralized configuration management
- JSON-based configuration storage
- Dynamic configuration loading
- Environment-specific settings
The platform includes comprehensive data analysis capabilities:
- Strike Price Analysis: Options strike price visualization
- Candlestick Charts: 5-minute interval market analysis
- Historical Data Processing: Automated report generation
- Performance Metrics: Trading strategy backtesting
- Secure API key management
- Two-factor authentication support
- Session management and token refresh
- Error handling and logging
Comprehensive logging system with:
- Application-level logging in
Log/directory - Strategy-specific logs for debugging
- Error tracking and monitoring
- Process execution logs
Robust process management with:
- Automated process monitoring
- Recovery mechanisms for failed processes
- Shell script-based process control
- Cron job integration for scheduling
- Fork the repository
- Create a feature branch (
git checkout -b feature/new-feature) - Commit your changes (
git commit -am 'Add new feature') - Push to the branch (
git push origin feature/new-feature) - Create a Pull Request
This software is for educational and research purposes only. Trading in financial markets involves substantial risk of loss. Users should:
- Thoroughly test strategies in paper trading mode
- Understand the risks involved in automated trading
- Comply with all applicable regulations
- Use proper risk management techniques
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Review the documentation in each module
- Check the logs for debugging information
Note: Make sure to properly configure your Zerodha API credentials and test thoroughly before using in live trading environments.