A robust and efficient trading platform that allows users to buy and sell stocks in real-time.
- Users can create an account, login and logout securely
- Users can view their portfolio, including their current holdings and total value
- Users can place market or limit orders to buy or sell stocks
- Users can view their order history and pending orders
- Admins can add new stocks to the platform
- Charts are available to visualize stock prices over time
- Flask endpoints have been thoroughly tested
GET /
: displays the home pageGET /login
: displays the login pagePOST /login
: logs in the userGET /register
: displays the registration pagePOST /register
: registers the userGET /logout
: logs out the userGET /stocks
: displays a list of all available stocksGET /stocks/<stock_id>
: displays detailed information about a specific stockPOST /buy
: allows the user to buy a stockPOST /sell
: allows the user to sell a stockGET /orderbook
: displays the order bookGET /chart/<stock_id>
: displays a chart of the price history for a specific stockGET /admin
: displays the admin dashboard (requires admin login)POST /admin/add_stock
: adds a new stock to the platform (requires admin login)
-
Clone the repository:
git clone https://github.com/your-username/trading-platform.git cd trading-platform
-
Create and activate a virtual environment:
python -m venv env source env/bin/activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Create the database and tables:
python db.py
-
Start the Flask app:
export FLASK_APP=run.py export FLASK_ENV=development flask run
-
Visit
http://localhost:5000
in your web browser to access the app.
-
Create a user account by clicking on the "Register" link in the top right corner of the app. You will be redirected to the registration page where you can create a new account by providing a username, email and password.
-
Log in to the app using the username and password you just created. You will be redirected to the dashboard where you can view your portfolio, place orders and view your order history.
-
To place an order, click on the "Place Order" button on the dashboard. You can then select a stock to trade, the type of order (market or limit) and the quantity you wish to trade.
-
To view your order history, click on the "Order History" link in the top right corner of the app. You can view your completed orders as well as any pending orders.
-
To view charts of the stock prices over time, click on the "Charts" link in the navigation bar. You can then select a stock to view the chart for.
-
If you are an admin user, you can add new stocks to the platform by clicking on the "Admin" link in the navigation bar and then clicking on the "Add Stock" button.
-
Fork the repository.
-
Create a new branch:
git checkout -b my-feature-branch
-
Make changes and commit them:
git add . git commit -m "Add new feature"
-
Push your changes to your fork:
git push origin my-feature-branch
-
Create a pull request.
This project is licensed under the MIT License - see the LICENSE.md file for details.