Skip to content

singadarsh790-cmyk/CodeAlpha_Python_Stock_Portfolio_tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Stock Portfolio Tracker

A simple Python command-line tool built for CodeAlpha – Python Programming Internship (Task 2).

Author: Adarsh Singh

Goal

Build a stock tracker that calculates total investment based on manually defined (hardcoded) stock prices.

How It Works

  • The user enters stock symbols and quantities.
  • Stock prices are pulled from a hardcoded dictionary, e.g.:
    {"AAPL": 180, "TSLA": 250, "GOOGL": 140, "AMZN": 175, "MSFT": 410}
  • The program calculates the total value of each holding and the overall total investment.
  • The user can optionally save the summary to a .txt or .csv file.

Key Concepts Used

  • Dictionaries
  • Input/Output (user input, console output)
  • Basic arithmetic
  • File handling (optional .txt / .csv export)

How to Run

  1. Make sure you have Python 3 installed.
  2. Download stock_portfolio_tracker.py from this repo.
  3. Open a terminal in that folder and run:
    python stock_portfolio_tracker.py
    
  4. Follow the on-screen prompts to enter stock symbols and quantities. Type done when finished.

Example Run

Stock symbol (e.g. AAPL): AAPL
Quantity of AAPL: 10
Stock symbol (e.g. AAPL): TSLA
Quantity of TSLA: 5
Stock symbol (e.g. AAPL): done

----- Portfolio Summary -----
AAPL: 10 shares x $180 = $1800
TSLA: 5 shares x $250 = $1250
------------------------------
TOTAL INVESTMENT: $3050
------------------------------

Save results to a file? (y/n): y
Save as 'txt' or 'csv'? csv
Saved to portfolio_summary.csv

Files

  • stock_portfolio_tracker.py – main program

Part of the CodeAlpha Python Programming internship – Module 1, Task 2. Created by Adarsh Singh

About

A simple Python command-line stock portfolio tracker that calculates total investment based on user-entered stocks and hardcoded prices — built for the CodeAlpha Python Programming internship

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages