A comprehensive stock scanner and backtesting platform for the Nifty Microcap 250 index.
- Stock Scanner: Scan for trading signals across multiple strategies
- Backtesting: Test strategies on historical data
- Portfolio Management: Track and analyze your portfolio
- Technical Analysis: Visualize stock charts with indicators
- Mock Data Support: Run without API credentials using mock data
- API Rate Limit Management: Process data in batches to avoid API rate limits
- Clone the repository:
git clone https://github.com/yourusername/cd-algo.git
cd cd-algo- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt-
Install TA-Lib (Technical Analysis Library):
On macOS:
brew install ta-lib pip install ta-lib
On Windows: Download and install the wheel file from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#ta-lib
On Linux:
wget http://prdownloads.sourceforge.net/ta-lib/ta-lib-0.4.0-src.tar.gz tar -xzf ta-lib-0.4.0-src.tar.gz cd ta-lib/ ./configure --prefix=/usr make sudo make install pip install ta-lib -
Install Streamlit:
Using the provided scripts:
- On macOS/Linux:
./install_streamlit.sh - On Windows:
install_streamlit.bat
Or manually:
pip install streamlit watchdog
- On macOS/Linux:
- Create a
.envfile in the root directory with your Kite API credentials:
KITE_API_KEY=your_api_key
KITE_API_SECRET=your_api_secret
- (Optional) Customize settings in
config/config.py
streamlit run dashboard/app.pyThe application supports mock data generation, allowing you to test functionality without API credentials:
- Launch the dashboard
- Check the "Use Mock Data" option in the sidebar
- Run scans and backtests with generated data
- Navigate to the Scanner page
- Select a strategy (or "all" to run all strategies)
- Adjust the maximum number of stocks to scan
- Configure batch processing settings to avoid API rate limits:
- Batch Size: Number of stocks to process in each batch
- Delay Between Batches: Time to wait between batches
- Max Parallel Workers: Maximum number of concurrent API requests
- Click "Run Scan"
- Navigate to the Backtesting page
- Select a strategy and symbol
- Set the date range and strategy parameters
- Configure batch processing for API requests:
- Enable "Use Batch Processing" to split data requests into smaller batches
- Set "Days Per Batch" and "Delay Between Batches" to manage API load
- Click "Run Backtest"
The platform includes the following strategies:
- Momentum Breakout: Identifies stocks breaking out of consolidation patterns with increased volume
- Mean Reversion: Finds oversold/overbought stocks likely to revert to their mean
- Gap and Go: Identifies stocks with significant gaps that continue in the direction of the gap
- VWAP Bounce: Looks for stocks bouncing off the Volume Weighted Average Price
- Relative Strength: Identifies stocks outperforming their sector or the broader market
The application includes several features to manage API rate limits:
- Batch Processing: Processes stocks in smaller batches with delays between batches
- Request Throttling: Limits the number of concurrent API requests
- Exponential Backoff: Automatically retries failed requests with increasing delays
- Mock Data Fallback: Generates mock data when API limits are reached
These features help avoid "Too many requests" errors from the Kite API.
- "Command not found: streamlit": Make sure you've activated your virtual environment and installed Streamlit using the provided scripts
- API Authentication Errors: Verify your API credentials in the .env file
- "Too many requests" Errors: Reduce batch size, increase delay between batches, or reduce the number of parallel workers
This project is licensed under the MIT License - see the LICENSE file for details.