A menu-driven Stock Portfolio Tracker developed in Python as part of the CodeAlpha Python Programming Internship.
This application helps users manage their stock investments by adding, removing, and updating stock holdings while calculating portfolio value and profit/loss. It also allows exporting reports in TXT or CSV format and automatically saves portfolio data between sessions.
- π View available stocks and their prices
- β Add (buy) stocks
- β Remove (sell) stocks
- πΉ Update stock prices
- π Calculate total portfolio value
- π° Track profit and loss (per stock and overall)
- π Visual portfolio allocation chart (ASCII bar chart)
- π Automatic portfolio data saving using JSON
- π Export portfolio reports in TXT or CSV format
- π¨ Optional colored terminal interface (works without Colorama as well)
- β Input validation and user-friendly menu
- Python 3
- JSON
- CSV
- Datetime
- OS Module
- Colorama (Optional)
CodeAlpha_StockPortfolioTracker/
βββ stock_portfolio_tracker.py
βββ README.md
βββ .gitignore
Note:
portfolio_data.jsonis created automatically the first time you run the app (it stores your personal portfolio data). It is not included in the repository β see.gitignore.
- Make sure Python 3 is installed.
- Download or clone this repository.
- Open the project folder in your terminal.
- Run the following command:
python stock_portfolio_tracker.pyOptional: Install Colorama for a colored terminal interface.
pip install coloramaThe application also works correctly without Colorama (plain text mode).
This project demonstrates the use of:
- Dictionaries
- Functions
- Loops
- Conditional Statements
- File Handling (JSON & CSV)
- Exception Handling
- Modular Programming
- User Input Validation
Saleha Shahid BS Electrical Engineering University of Management and Technology (UMT)
CodeAlpha β Python Programming Internship