Welcome to a simplified way of tracking stock information.
Click here to access the repo.»
Table of Contents
We have built a Flask-based web application that allows registered users to track pricing information about their selected stocks, as well as to stay up-to-date with the financial news most relevant to those tracked stocks through integration with external APIs.
- User Registration: Users can create an account by providing their email, first name, last name, and password. Passwords are securely hashed and stored in a MySQL database. Users are also required to enter at least three ticker symbols (i.e. stock identifiers) of those stocks they would like to track.
- User Login: Registered users can log in to their accounts using their email and password for their tracked stocks to display on their stock dashboard.
- User Logout: Users can log out from their account, which redirects the user to the login page.
- 'Remember Me' (for Registered Users): Registered users do not need to log in as they will remain logged in for easy access unless they have previously logged out.
- Stock Dashboard: After logging in, users are presented with a dashboard that displays their selected stocks' pricing data as well as most relevant news articles. Pricing information is fetched using the Alpha Vantage API and includes a visual representation of daily closing prices from the beginning of the year (2023) identified with the stock's the ticker symbol, the stock's latest closing price (yesterday's price) in USD, the stock's day-before-yesterday's closing price in USD, the percentage difference between the two, and the direction of the price change (i.e. whether the price has gone up or down). The news articles are fetched from an API based on the user's stock preferences.
- Stock Selection: Users can ammend their stock preferences in the 'Stock Selection' page.
- Personal Information Management: Users can ammend their personal details (including their password) in the 'My Account' page.
- Notifications and Alerts: Users are notified via email (using Sendgrid) if their tracked stocks' price has changed by more than a user-defined threshold.
- auth.py: This file contains the authentication-related routes, including user registration, login, logout, and password update.
- models.py: This file defines the database models used by the application. It includes the User model, which represents the user accounts and their associated fields.
- views.py: This file contains the main routes and logic for rendering the dashboard, fetching stock data and news articles, and handling user actions.
- config.py: This file stores the configuration variables for the application, such as database credentials.
- total_stock_list.py: This file contains a list of valid stock symbols used for validation purposes.
- templates/: This directory contains the HTML templates used for rendering the web pages. Including the base, home, settings, sign_up and stock_setting HTML Files.
To get a local copy up and running follow these simple example steps.
The application requires the following dependencies (amongst others) which can be installed from the requirements.txt (see Installation below):
- Flask: A micro web framework used for building the web application.
- Flask-Login: A Flask extension that handles user authentication and session management.
- Flask-WTF: A Flask extension that simplifies the handling of forms.
- SQLAlchemy: A Python SQL toolkit and Object-Relational Mapping (ORM) library used for database operations.
- PyMySQL: A MySQL client library used for connecting to the MySQL database.
- SendGrid: A library for sending emails, used for password reset functionality.
- Requests: A library for making HTTP requests, used for fetching data from external APIs.
- Werkzeug: A library used for password hashing and verification.
-
Get a free API Key for Alpha Vantage, News API, SendGrid at https://www.alphavantage.co/, https://newsapi.org and https://interactive.twilio.com/email-brand-signup-sales, respectively.
-
Ensure that Python 3.x is installed on your system.
-
Clone the repo
git clone https://github.com/Stock-News-Monitoring-Program/Final_Version_With_Notifications.git
-
Navigate to the project directory
cd Final_Version_With_Notifications -
Create a virtual environment to isolate the project's dependencies
python3 -m venv venv
-
Activate the virtual environment
venv\Scripts\activate
-
Install requirements
pip install -r requirements.txt
-
Ensure that you have a MySQL database set up and running
- Create a database called 'stock'
-
Configure the application Within the config.py, ensure the following variables match your database credentials
- HOST
- PORT
- USER
- PASSWORD
- DATABASE
-
Enter your API in
views.py -
Initialise the database
flask db init flask db migrate -m "Initial migration" flask db upgrade -
Start the application
flask run
-
Open your web browser and visit http://localhost:5000 to access the application.
For more examples, please refer to the Documentation
- Ensuring scalability by deploying the application and moving the database to the cloud.