Izemaj / stock-price-checker-automation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stock Price Checker

This program fetches the closing prices of a stock for the last two days from AlphaVantage API, calculates the percentage difference between the prices, fetches news articles related to the company, and sends SMS messages using Twilio API based on the percentage difference in stock prices.

Functions

The program is divided into several functions:

  • get_stock_prices(): This function fetches the closing prices of a stock for the last two days from AlphaVantage API.
  • calculate_percentage_difference(): This function calculates the percentage difference between the closing prices.
  • get_news(): This function fetches news articles related to the company using News API.
  • send_messages(): This function sends an SMS message using Twilio API based on the percentage difference in stock prices.
  • main(): This function calls all the other functions in the correct order to execute the program.

How it works

The automation script fetches the closing prices of a stock for the last two days using the AlphaVantage API after prompting for the stock symbol. It then calculates the percentage difference between the prices and checks if it's a significant change. If it is significant, the script fetches news articles related to the company using the News API. In the final step, it sends an SMS message through the Twilio API to inform you about the change in stock prices and provide a summary of the news articles.

Requirements

  • Python 3.x
  • Requests library
  • Twilio library
  • News API key
  • AlphaVantage API key
  • Twilio account and phone number

Usage

  1. Clone the repository to your local machine.
  2. Install the required libraries using pip:
  3. pip install twilio
    pip install requests
  4. Update the enviroment variables with your News API key, AlphaVantage API key, Twilio account SID, auth token, and phone number.
  5. Run the program:
  6. python main.py

Before running the program, make sure you have signed up for a Twilio account and obtained a Twilio phone number, as well as acquired your News API key and AlphaVantage API key. The program will automatically fetch the closing prices of a stock for the last two days using the AlphaVantage API, calculate the percentage difference between the prices, fetch news articles related to the company using the News API, and send SMS messages using the Twilio API based on the percentage difference in stock prices.

About


Languages

Language:Python 100.0%