Skip to content

Chinmay921/nifty-microcap-scanner

Repository files navigation

Nifty Microcap 250 Stock Scanner

A comprehensive stock scanner and backtesting platform for the Nifty Microcap 250 index.

Features

  • 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

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/cd-algo.git
cd cd-algo
  1. Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. 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
  2. Install Streamlit:

    Using the provided scripts:

    • On macOS/Linux: ./install_streamlit.sh
    • On Windows: install_streamlit.bat

    Or manually:

    pip install streamlit watchdog

Configuration

  1. Create a .env file in the root directory with your Kite API credentials:
KITE_API_KEY=your_api_key
KITE_API_SECRET=your_api_secret
  1. (Optional) Customize settings in config/config.py

Usage

Running the Dashboard

streamlit run dashboard/app.py

Using Mock Data

The application supports mock data generation, allowing you to test functionality without API credentials:

  1. Launch the dashboard
  2. Check the "Use Mock Data" option in the sidebar
  3. Run scans and backtests with generated data

Scanning for Signals

  1. Navigate to the Scanner page
  2. Select a strategy (or "all" to run all strategies)
  3. Adjust the maximum number of stocks to scan
  4. 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
  5. Click "Run Scan"

Running Backtests

  1. Navigate to the Backtesting page
  2. Select a strategy and symbol
  3. Set the date range and strategy parameters
  4. 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
  5. Click "Run Backtest"

Strategies

The platform includes the following strategies:

  1. Momentum Breakout: Identifies stocks breaking out of consolidation patterns with increased volume
  2. Mean Reversion: Finds oversold/overbought stocks likely to revert to their mean
  3. Gap and Go: Identifies stocks with significant gaps that continue in the direction of the gap
  4. VWAP Bounce: Looks for stocks bouncing off the Volume Weighted Average Price
  5. Relative Strength: Identifies stocks outperforming their sector or the broader market

API Rate Limit Management

The application includes several features to manage API rate limits:

  1. Batch Processing: Processes stocks in smaller batches with delays between batches
  2. Request Throttling: Limits the number of concurrent API requests
  3. Exponential Backoff: Automatically retries failed requests with increasing delays
  4. Mock Data Fallback: Generates mock data when API limits are reached

These features help avoid "Too many requests" errors from the Kite API.

Troubleshooting

Common Issues

  1. "Command not found: streamlit": Make sure you've activated your virtual environment and installed Streamlit using the provided scripts
  2. API Authentication Errors: Verify your API credentials in the .env file
  3. "Too many requests" Errors: Reduce batch size, increase delay between batches, or reduce the number of parallel workers

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

Nifty Microcap 250 Stock Scanner with 5 trading strategies, ML predictions, and risk management

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages