Day 58 of 100 Days Coding Challenge: Python
Today, I finally unlocked the magic of seeing live stock prices for the companies I’ve been tracking. I activated the virtual environment I had so carefully crafted for this project—like slipping into a freshly pressed lab coat—and copied my previous file to create the next version. This has become my ritual. I don’t trust myself enough to overwrite yesterday’s work. I’ve learned the hard way: one misstep, and suddenly you’re debugging into the void at midnight.
But this time, everything felt smoother. More methodical. Like my stock tracker finally got itself a LinkedIn profile and a morning routine. I added the new function and, for the first time, watched real prices pop up for the stocks I entered. It was like watching your kid take their first steps… except your kid is Apple and it’s walking straight into your fantasy portfolio.
Today’s Motivation / Challenge
Sure, it’s fun to say you’re tracking stocks—but it’s even better to see what they’re actually worth. Today’s goal was to bring those tickers to life with live price data. It’s like turning a guest list into a party: you know who’s there, but now you see what they’re wearing. A clean interface that pulls prices makes the tracker feel real—and a lot more useful than a plain list of letters.
Purpose of the Code (Object)
This update adds a function that displays all currently tracked stocks alongside their latest prices pulled from Yahoo Finance. It keeps things simple and readable, so users can check their “portfolio” at a glance without needing to log into a brokerage or scroll through a financial website.
AI Prompt:
Add a function to a Python script that displays all stock symbols in a list along with their current market prices using the yfinance library.
Functions & Features
- Add stock symbols
- Remove stock symbols
- Show tracked symbols
- View current stock prices
- Exit the program (option 99, always last)
Requirements / Setup
pip install yfinance
You’ll also need Python 3.8+ and a virtual environment (optional but recommended).
Minimal Code Sample
import yfinance as yf
def view_portfolio():
for symbol in load_stocks():
price = yf.Ticker(symbol).info.get(‘regularMarketPrice’)
print(f”{symbol}: ${price:.2f}” if price else f”{symbol}: Price unavailable”)
Fetches and displays each stock’s latest price using Yahoo Finance.
Notes / Lessons Learned
For this feature, I added the yfinance library and made sure to import it up top with the rest of the code crew. I also handled the situation where your portfolio might be empty—no one likes being told they have nothing, but it’s better than a crash. Thankfully, all the stocks I added yesterday were valid, so prices rolled in smoothly like a stock market ticker parade.
The function pulls from regularMarketPrice, which seems to be the most consistent for daily price checks. There were no errors, no false alarms, and no imaginary companies to spoil the moment. Just sweet, sweet confirmation that this tracker is starting to walk, maybe even jog.
Optional Ideas for Expansion
- Show daily percentage change or price movement alongside current price
- Highlight gains and losses in green/red
- Let users refresh prices without restarting the script
Day 58 marks the moment this project stopped being theoretical. It’s starting to feel real—and I’m here for it.

