Skip to content

This program was created as the final project for CS50’s Introduction to Programming with Python (CS50P), a course offered by Harvard University.

License

Sanjaykumar030/CS50P-FinalProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Stock Log

Python CSV Persistence UI with Tabulate Tested with pytest License: MIT DOI



✨ Overview

Stock Log is a terminal-based stock portfolio tracker written in Python, built as a final project for CS50’s Introduction to Programming with Python (CS50P).

This lightweight app helps you record and manage stock transactions using a clean command-line interface and stores entries in a portable CSV file.


🧠 Core Features

  • 🖥️ Menu-driven interaction via Python’s match statement
  • 💹 Track Buy/Sell actions for stocks
  • 🔢 Input fields: ticker symbol, quantity, price, and date
  • 📄 CSV-based persistence (no database needed)
  • 📊 Display entries in a formatted table using tabulate
  • Robust error handling for invalid inputs
  • 🧪 Unit tested with pytest (includes I/O simulation)

📋 Menu Options

  1. ➕ Add a new entry
  2. ✏️ Update an existing entry
  3. ❌ Delete an entry
  4. 📋 View all entries
  5. 🚪 Exit

📂 File Structure

File Purpose
project.py Main logic, interactive menu, and helper functions (main(), etc.)
test_project.py Unit tests for core logic using pytest
stock.csv Stores your stock entries (auto-created and updated)
requirements.txt Lists required libraries (tabulate, cowsay)

🛠️ Design Decisions

  • CSV file is used to keep things simple and portable—ideal for beginners.
  • Functions like validate_action() and calculate_total_price() are broken out for modularity and testability.
  • Focus was kept on clarity, correctness, and clean code, rather than excessive features.

🧪 Testing Strategy

  • ✅ Input validation and calculation logic are unit-tested
  • ✅ Uses tmp_path fixture in pytest to safely test file-writing logic without touching your real CSV file

🚧 Challenges Faced

  • Managing updates and deletions in CSV required careful file rewrites
  • Simulating file I/O for tests was tricky at first—learned tmp_path fixture to solve it!
  • Improving input error handling took time but made the app much smoother to use

✅ Conclusion

Stock Log is a beginner-friendly, real-world application that combines essential programming concepts like:

  • File handling
  • User input validation
  • Error management
  • Modular design
  • Automated testing

Whether you're just learning Python or want a basic terminal app for tracking your stocks, Stock Log is ready to use and extend.


👤 Author

Sanjay Kumar Sakamuri Kamalakar
📧 sksanjaykumar010307@gmail.com
🔗 LinkedIn
🧪 ORCID: 0009-0009-1021-2297


📝 License

This project is licensed under the MIT License.
See the LICENSE file for full details.


🙏 Acknowledgements

  • Thanks to the CS50 team and all open-source developers behind Python libraries
  • Special appreciation to my professors and peers who supported this learning journey

🎉 Thank you for checking out Stock Log! If you like it, feel free to star ⭐ the repo or fork it and build your own version!

About

This program was created as the final project for CS50’s Introduction to Programming with Python (CS50P), a course offered by Harvard University.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages