This is a Flask-based web application that allows users to manage their stock portfolio. It supports login functionality, buying stocks, viewing transaction history, and fetching stock quotes. The app uses SQLite for storing user data and stock transactions.
- User Authentication: Login and user session management.
- Stock Portfolio Management: View and manage a portfolio of stocks.
- Password Validation: Strong password policies are enforced.
- User Authentication: Users can register, log in, and update their account information.
- Stock Quote Lookup: Users can enter a stock symbol to get the latest quote for the stock.
- Buy and Sell Shares: Users can buy or sell shares they own,by providing the stock symbol and the number of shares.
- Transaction History: Users can view a history of their transactions.
- User Profile Update: Users can update their username, email, and password.
- Displays basic information about the application and provides links to other pages like Quote, Buy, Sell, and History.
- URL:
/login
- Allows users to log in by entering their username and password.
- URL:
/register
- Allows users to create an account by providing a username, password, and password confirmation.
- URL:
/quote
- Allows users to look up stock symbols by entering a symbol (e.g.,
AAPL
) and retrieving the latest stock price.
- URL:
/quoted
- Displays the price of the stock corresponding to the symbol entered on the Quote page.
- URL:
/sell
- Allows users to select a stock symbol and enter the number of shares to sell.
- URL:
/update
- Allows users to update their username, email, and password.
-
Clone the repository:
git clone https://github.com/Elhussin/financeFlask.git cd stock-trading-app
-
Install the required Python packages:
pip install -r requirements.txt
To start the application, run:
python app.py
flask run
The application will be available at http://127.0.0.1:5000/
.
- Go to the Register page (
/register
) to create an account. - After registration, you will be redirected to the Login page (
/login
). Enter your credentials to log in.
- Go to the Quote page (
/quote
) and enter a stock symbol (e.g.,AAPL
). - View the latest stock price on the Quoted page (
/quoted
).
- On the Sell page (
/sell
), select a stock symbol from your owned items and enter the number of shares you want to sell. - The Buy page (
/buy
) allows you to purchase shares.
- Go to the Update page (
/update
) to update your username, email, and password. Make sure to meet the password requirements.
- If there is an error with form validation (e.g., empty fields, password requirements not met), the application will show an error message.
Displays an apology message to the user, typically used for error handling.
A decorator that ensures the user is logged in before accessing certain routes.
Fetches the latest stock price for a given stock symbol from Yahoo Finance.
Formats a given value as USD currency (e.g., $1,234.56
).
Validates that the password meets the following criteria:
- Length between 8 and 20 characters.
- Contains at least one digit.
- Contains at least one uppercase letter.
- Contains at least one lowercase letter.
- Contains at least one special character from the set:
$ @ # % & *
.
- / (Home): Displays the user's stock portfolio with cash balance and stock summary.
- /buy (Buy Stocks): Allows users to buy stocks by providing a symbol and the number of shares.
- /history (Transaction History): Displays a history of all the user's stock transactions.
- /login (Login): Allows users to log into their account.
- /logout (Logout): Logs out the current user.
- /quote (Stock Quotes): Allows users to look up the latest stock quote for a given symbol.
How to Use
- Register and Log In Go to the Register page (/register) to create an account. After registration, you will be redirected to the Login page (/login). Enter your credentials to log in.
- Look Up Stock Quotes Go to the Quote page (/quote) and enter a stock symbol (e.g., AAPL). View the latest stock price on the Quoted page (/quoted).
- Buy/Sell Shares On the Sell page (/sell), select a stock symbol from your owned items and enter the number of shares you want to sell. The Buy page (/buy) allows you to purchase shares.
- Update Your Account Information Go to the Update page (/update) to update your username, email, and password. Make sure to meet the password requirements. Error Messages If there is an error with form validation (e.g., empty fields, password requirements not met), the application will show an error message.
This project is licensed under the MIT License - see the LICENSE file for details.