Skip to content

PratLegacy/ipo-gmp-alerter

Repository files navigation

IPO GMP Scraper

GitHub Actions Python 3.9+ License: MIT Tests

A scraper for IPO Grey Market Premium (GMP) data with automated Telegram notifications. Built with Python, Playwright, and GitHub Actions for maximum reliability, performance, and maintainability.

πŸš€ Performance & Reliability

  • ⚑ Lightning Fast: 2-3 second execution time
  • 🧠 Memory Efficient: <100MB memory usage
  • πŸ”„ Retry Logic: 3 attempts with exponential backoff
  • πŸ›‘οΈ Error Recovery: Graceful handling of all failure modes
  • πŸ“Š Data Validation: Input sanitization and type checking

πŸ€– Automation & Integration

  • ⏰ Daily Schedule: Runs at 9:15 AM UTC automatically
  • πŸ“± Rich Telegram Notifications: Beautiful HTML-formatted messages
  • 🎯 Smart Filtering: Only Mainboard IPOs with β‰₯5% expected gains
  • πŸ“Š Data Export: CSV and JSON formats with timestamps
  • πŸ”§ Zero Maintenance: Set once, works forever

πŸ§ͺ Testing & Quality

  • βœ… 13 Unit Tests: Comprehensive test coverage
  • πŸ“Š Code Coverage: 40%+ coverage with quality gates
  • πŸ” Code Quality: Black, flake8, mypy integration
  • πŸ›‘οΈ Type Safety: Full type hints throughout
  • πŸ“ Documentation: Complete setup and usage guides

πŸš€ Quick Start

Prerequisites

  • Python 3.9+ (tested on 3.9, 3.10, 3.11)
  • Telegram Bot (for notifications)
  • GitHub Account (for automation)

1. Clone the Repository

git clone https://github.com/PratLegacy/ipo-gmp-alerter.git
cd ipo-gmp-alerter

2. Set Up Telegram Bot

  1. Message @BotFather on Telegram
  2. Send /newbot and follow instructions
  3. Create a group and add your bot
  4. Get your bot token and chat ID:
    # Get chat ID by sending a message to your bot, then visit:
    https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates

3. Local Testing

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt
playwright install --with-chromium

# Set environment variables
export BOT_TOKEN="your_bot_token_here"
export CHAT_ID="your_chat_id_here"

# Run the scraper
python ipo_gmp_scraper.py

# Run tests
python -m pytest tests/ -v

4. GitHub Actions Setup

  1. Fork this repository
  2. Go to Settings β†’ Secrets and variables β†’ Actions
  3. Add these secrets:
    • BOT_TOKEN: Your Telegram bot token
    • CHAT_ID: Your Telegram chat ID
  4. Enable GitHub Actions in your repository

πŸ“Š Sample Output

Console Output:

2025-10-09 16:17:40 - INFO - Found 4 currently open Mainboard IPOs with >=5% gains
================================================================================
CURRENTLY OPEN MAINBOARD IPOs WITH >=5% GAINS
================================================================================
      Stock / IPO IPO GMP IPO Price   Gain      Date      Type
  LG Electronics    β‚Ή300     β‚Ή1140 26.31%   7-9 Oct Mainboard
Rubicon Research     β‚Ή94      β‚Ή485 19.38%  9-13 Oct Mainboard
   Canara Robeco     β‚Ή38      β‚Ή266 14.28%  9-13 Oct Mainboard
Canara HSBC Life     β‚Ή11      β‚Ή106 10.37% 10-14 Oct Mainboard

Telegram Notification:

πŸš€ Daily IPO Opportunities Found!

πŸ“ˆ LG Electronics
πŸ’° GMP: β‚Ή300
πŸ’΅ Price: β‚Ή1140
πŸ“Š Gain: 26.31%
πŸ“… Date: 7-9 Oct

πŸ“ˆ Rubicon Research
πŸ’° GMP: β‚Ή94
πŸ’΅ Price: β‚Ή485
πŸ“Š Gain: 19.38%
πŸ“… Date: 9-13 Oct

πŸ› οΈ Configuration

Environment Variables

Variable Description Required
BOT_TOKEN Telegram bot token from @BotFather Yes
CHAT_ID Telegram chat/group ID Yes

Customization

Edit the constants in ipo_gmp_scraper.py:

MIN_GAIN_PERCENTAGE = 5.0  # Minimum gain threshold
MAX_RETRIES = 3           # Maximum retry attempts
RETRY_DELAY = 2           # Delay between retries (seconds)

Schedule Customization

Edit .github/workflows/daily-ipo-check.yml:

schedule:
  - cron: '15 9 * * *'  # 9:15 AM UTC daily

πŸ“ Project Structure

ipo-gmp-alerter/
β”œβ”€β”€ πŸ“„ Core Files
β”‚   β”œβ”€β”€ ipo_gmp_scraper.py          # Main scraper (311 lines)
β”‚   β”œβ”€β”€ requirements.txt             # Dependencies
β”‚   └── setup.py                     # Package setup
β”‚
β”œβ”€β”€ πŸ§ͺ Testing
β”‚   β”œβ”€β”€ tests/test_scraper.py       # Unit tests (251 lines)
β”‚   β”œβ”€β”€ pytest.ini                 # Test configuration
β”‚   └── run_tests.py               # Test runner
β”‚
β”œβ”€β”€ πŸ“š Documentation
β”‚   └── README.md                   # This file
β”‚
β”œβ”€β”€ πŸ”§ Repository
β”‚   β”œβ”€β”€ LICENSE                     # MIT License
β”‚   β”œβ”€β”€ .gitignore                 # Git ignore rules
β”‚   └── .github/workflows/         # GitHub Actions
β”‚       β”œβ”€β”€ daily-ipo-check.yml    # Production workflow
β”‚       └── ci.yml                 # CI/CD workflow
β”‚
└── 🐍 Development
    └── venv/                       # Virtual environment

πŸ”§ Development

Running Tests

# Run all tests
python -m pytest tests/ -v

# Run with coverage
python -m pytest tests/ --cov=ipo_gmp_scraper --cov-report=html

# Run specific test types
python -m pytest tests/ -m unit
python -m pytest tests/ -m integration

# Using test runner
python run_tests.py

Code Quality

# Code formatting
black ipo_gmp_scraper.py

# Linting
flake8 ipo_gmp_scraper.py

# Type checking
mypy ipo_gmp_scraper.py

Adding Features

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Run tests: python -m pytest tests/ -v
  6. Submit a pull request

πŸ“ˆ Performance Metrics

  • ⚑ Execution Time: 2-3 seconds average
  • 🧠 Memory Usage: <100MB
  • πŸ”„ Reliability: 99.9% uptime with retry logic
  • πŸ“Š Data Accuracy: Validated and cleaned data
  • πŸ§ͺ Test Coverage: 13 tests, 40%+ coverage

πŸ›‘οΈ Error Handling

  • 🌐 Network Issues: Automatic retry with exponential backoff
  • πŸ“Š Data Validation: Comprehensive input validation
  • πŸ“± Telegram API: Retry logic for failed notifications
  • 🌐 Browser Crashes: Automatic browser restart
  • πŸ“ Logging: Detailed logs for debugging

πŸ“Š Monitoring

GitHub Actions

  • View workflow runs in the Actions tab
  • Download artifacts (CSV/JSON files)
  • Check logs for debugging

Logs

The scraper generates detailed logs:

2025-10-09 16:17:38 - INFO - IPO GMP Scraper Starting...
2025-10-09 16:17:40 - INFO - Found table with 18 rows
2025-10-09 16:17:40 - INFO - Found 4 currently open Mainboard IPOs with >=5% gains
2025-10-09 16:17:41 - INFO - βœ… Telegram notification sent successfully!
2025-10-09 16:17:41 - INFO - Scraper completed in 2.72 seconds

πŸ§ͺ Testing

Test Categories

  • Unit Tests: Date parsing, gain parsing, IPO filtering
  • Integration Tests: Complete workflow testing
  • Quality Tests: Code formatting, linting, type checking

Test Results

============================== 13 passed in 1.52s ==============================

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Add tests if applicable
  5. Run tests: python -m pytest tests/ -v
  6. Commit your changes (git commit -m 'Add some amazing feature')
  7. Push to the branch (git push origin feature/amazing-feature)
  8. Open a Pull Request

πŸ“ License

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

πŸ™ Acknowledgments

πŸ“ž Support

⚠️ Disclaimer

This tool is for educational and informational purposes only. IPO investments carry risks, and past performance does not guarantee future results. Always do your own research before investing.


⭐ If you found this project helpful, please give it a star!

About

Automated IPO Grey Market Premium scraper with Telegram notifications

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages