A practical console-based Stock Portfolio Tracker built with Python.
Calculate investment values based on predefined stock prices and securely store portfolio records.
The Stock Portfolio Tracker is a lightweight Python application designed to help users calculate the total value of their stock investments.
The program uses a predefined dictionary containing stock prices and allows users to enter stock symbols along with quantities owned. Based on the provided input, it computes the total investment value and stores the transaction details in an external text file for future reference.
This project demonstrates essential Python programming concepts such as dictionary operations, file handling, input processing, and basic financial calculations.
- Predefined Stock Price Database using a hardcoded dictionary of stock values.
- Case-Insensitive Ticker Input allowing users to enter stock symbols in any letter case.
- Automatic Investment Calculation to instantly determine total portfolio value.
- Persistent Record Storage by saving portfolio details to
portfolio.txt. - Input Validation that gracefully handles unavailable stock symbols.
Enter stock name: aapl
Enter quantity: 6
Total investment value: 1080
Result saved in portfolio.txt
Stock: AAPL
Quantity: 6
Investment Value: 1080
| Technology | Purpose |
|---|---|
| Python 3 | Core programming language |
| Dictionaries | Store stock prices and mappings |
| File I/O | Save portfolio records permanently |
| Type Casting | Process and validate user inputs |
Task2_Stock Portfolio Tracker/
│
├── main.py # Main application script
├── portfolio.txt # Stores portfolio records
└── README.md # Project documentation
git clone https://github.com/AqsaAliRazaJamali/CodeAlpha_Stock_Portfolio_Tracker.gitcd CodeAlpha_Stock_Portfolio_Trackerpython main.pyThis project showcases several fundamental Python concepts, including:
- Dictionary Data Structures
- User Input Handling
- String Manipulation (
.upper()) - Type Conversion (
int()) - Conditional Statements (
if-else) - Basic Arithmetic Operations
- File Handling using
with open() - Data Persistence using Append Mode (
"a")
This project was completed as Task 2 of the Python Programming Internship offered by CodeAlpha.
⭐ If you found this project useful, consider giving it a star!