Skip to content

A Telegram bot that allows users to check real-time stock prices and view charts of stock data. The bot fetches stock data from Yahoo Finance and responds with the latest stock price and can generate visual plots for stock performance over time.

Notifications You must be signed in to change notification settings

Ulton321/telegram_bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 

Repository files navigation

Telegram Bot Stock Checker

A Telegram bot that allows users to check real-time stock prices and view charts of stock data. The bot fetches stock data from Yahoo Finance and responds with the latest stock price and can generate visual plots for stock performance over time.

Features

  • Stock Price Lookup:
    Users can enter the ticker symbol of a stock, and the bot will respond with the latest closing price of that stock.

  • Plotting Stock Data:
    The bot can generate a plot of a stock’s historical data using its ticker symbol and send the generated plot as an image to the user.

  • Interactive Commands:

    • /stock <TICKER>: Returns the latest stock price of the specified ticker.
    • /plot <EXPRESSION>: Generates a plot based on a mathematical expression and sends it to the user.
    • /hello: Greets the user.
  • Real-Time Data Fetching:
    The bot fetches real-time stock price data using the Yahoo Finance API.

  • Graph Generation:
    Generate custom plots with the help of matplotlib for stock data or mathematical functions.

Installation

Prerequisites

  1. Python 3.7+
  2. Install the necessary libraries:
pip install -r requirements.txt

specify time ranges for historical data.

  • Moving Averages: Add options to calculate and overlay moving averages on stock charts for better trend analysis.

  • Portfolio Tracking: Enable users to track a portfolio of stocks and calculate performance metrics.

  • Improved Plot Customization: Add features like gridlines, annotations, multiple graph themes, and the ability to export high-resolution charts.

  • Alert System: Implement a notification system to alert users about stock price changes or specific thresholds.

  • Search by Company Name: Allow users to search for stock tickers by company name if they don’t know the symbol.

  • Deployment to Cloud Platforms: Provide a guide for deploying the bot on cloud services like AWS, Heroku, or Google Cloud for continuous availability.


Example Bot Interaction

Fetching a Stock Price

User Input:
/stock TSLA

Bot Response:

Generating a Plot

User Input:
/plot x**3 - 2*x

Bot Response:
(Sends a graph image)
"Here is the plot for the expression x**3 - 2*x over the range x = -10 to 10."

Greeting

User Input:
/hello

Bot Response:
"Hello there! I’m here to assist you with stock prices and charts."


Troubleshooting

  1. Bot Not Responding:

    • Ensure that the Telegram token in the .env file is correct.
    • Verify that the bot is running and connected to the internet.
  2. Dependency Issues:

    • Make sure all dependencies are installed correctly using pip install -r requirements.txt.
    • For any missing packages, try installing them manually.
  3. Yahoo Finance API Errors:

    • Check if the ticker symbol is valid.
    • Ensure that the yfinance package is up to date.
  4. Plot Not Rendering:

    • Verify that matplotlib is installed and functional.
    • Ensure the expression provided in /plot is valid Python syntax.

Contribution

We welcome contributions! Here’s how you can help:

  1. Fork the repository.

  2. Create a new branch for your feature or bug fix:

    git checkout -b feature-name

About

A Telegram bot that allows users to check real-time stock prices and view charts of stock data. The bot fetches stock data from Yahoo Finance and responds with the latest stock price and can generate visual plots for stock performance over time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages