Skip to content

A Python-based Telegram bot that tracks stock prices and sends alerts when specific price levels or moving averages are reached. Built with pyTelegramBotAPI and yfinance, this bot allows users to add, delete, and view stock alerts through a simple Telegram interface.

Notifications You must be signed in to change notification settings

kemaldahha/telegram-stock-alerts

Repository files navigation

📈 Telegram Stock Alerts Bot

A Python-based Telegram bot for managing stock price alerts 📊, using Yahoo Finance data (via the yfinance library) to track stocks and notify users when their desired price thresholds or moving averages are crossed.

Bot Usage

✨ Features

  • Add Alerts: Users can set alerts for specific stock tickers when the stock reaches a particular price level, percentage change, or moving average (e.g., MA100).
  • Delete Alerts: Users can easily remove alerts they no longer need.
  • Show All Alerts: Displays a list of all active alerts for the user, formatted with relevant stock and price data.
  • Automatic Price Checks: A background process periodically checks stock prices and triggers alerts when conditions are met 🔔.
  • Alert Types:
    • Price Level Alerts (e.g., when a stock crosses a specific price).
    • Percentage Alerts (e.g., 5% above or below the current price).
    • Moving Average Alerts (e.g., 100-day moving average).

🗂 Project Structure

  • bot.py: Contains the core logic of the Telegram bot 🤖. Handles user interactions like adding, deleting, and showing alerts, as well as validating stock tickers and price data.
  • check_alerts.py: A script that checks stock price data against user-set alerts and notifies users when conditions are met.
  • database.py: Manages SQLite database operations to store and retrieve alerts and chat information 🗄.
  • logger_config.py: Sets up logging for the project, writing events and errors to a log file 📝.
  • requirements.txt: Lists the Python packages required to run the project.
  • .gitignore: Ignores sensitive files such as the Telegram bot token, logs, and the database file.

🛠 Installation

  1. Clone the repository:

    git clone https://github.com/kemaldahha/telegram-stock-alerts.git
  2. Navigate to the project directory:

    cd telegram-stock-alerts
  3. Install the required packages:

    pip install -r requirements.txt
  4. Create a constants.py file with the following content:

    TELEGRAM_TOKEN = 'your_telegram_bot_token_here'

    Replace your_telegram_bot_token_here with your actual Telegram bot token.

About

A Python-based Telegram bot that tracks stock prices and sends alerts when specific price levels or moving averages are reached. Built with pyTelegramBotAPI and yfinance, this bot allows users to add, delete, and view stock alerts through a simple Telegram interface.

Resources

Stars

Watchers

Forks

Languages