Day 56 of 100 Days Coding Challenge: Python
Introduction to DIY Portfolio: A Python-Powered Stock Tracker (Day 56-Day75)
I’ve always had a curious relationship with investing. Back in my early twenties—just when online trading was beginning to sparkle with possibility—E*TRADE was running flashy stock-simulation competitions. I never had the nerve to join in, but the idea of tracking trades fascinated me. While others were glued to leaderboards, I was quietly watching market psychology unfold.
In one of my marketing classes, we studied consumer behavior, and I couldn’t help noticing the parallel. Stocks, like shoppers, are swayed by emotion. A bad headline sparks panic selling; a glowing report sends buyers rushing in. It was less about the spreadsheets and more about human nature in motion.
That said, I am no day trader. With a full-time job, I simply don’t have the bandwidth—or appetite—to chase tickers every second. Early on, I learned the hard truth: betting heavily on a single stock feels thrilling right up until it doesn’t. So I shifted to a disciplined rhythm. First, parking cash in money markets weekly, then funneling it into chosen investments. Eventually, I swapped most individual stocks for ETFs, which let me hedge my bets without needing caffeine-fueled midnight monitoring.
This is where my stock tracker comes in. It isn’t just a neat dashboard—it’s a sanity check. How much should live in bonds? How much in equities? The tracker keeps me honest, reminding me that a balanced pie chart beats chasing shiny objects.
Unlike my earlier Book Tracker project—where I bolted on features haphazardly and ended up cleaning a digital junk drawer—this time I built with a vision. The bigger the project, the less forgiving chaos becomes. Structure first, spaghetti later (preferably with marinara, not code).
What surprised me most was not the tracker itself but the realization of just how powerful Python can be. With a few libraries and some determination, I had built something that, in the past, I would have had to pay for—except now it’s tailored exactly to me. A personalized financial sidekick, minus the subscription fee.
Experience
Today marks the thrilling kickoff of a brand-new project: a stock tracking system. That’s right—I’m building a little Wall Street in my terminal. This time, I’ve sworn an oath to the ghost of Aristotle not to wing it. Last time, when I built a book tracker, I skipped the whole “final cause” thing—you know, the actual goal—and ended up redesigning everything from the menu to the data structure while muttering like a sleep-deprived philosopher. It was less “Eureka!” and more “Why did I do this to myself?” But not today. Today, I have a plan. A real roadmap. With arrows and everything. Step one? Get a stock symbol into the system without accidentally starting a recession.
Today’s Motivation / Challenge
We all want to be savvy investors, right? Or at least know what “diversification” means without Googling it every week. Today’s project is the first brick in a 20-day tower of financial wisdom—well, mock financial wisdom. We’re not handling real money here (unless you count emotional investment). The goal is simple: give users a way to start tracking the stocks they care about. It’s the tech equivalent of sticking Post-its on your fridge, but smarter—and less sticky.
Purpose of the Code (Object)
This tiny program lets you add stock symbols you want to track. It stores them in a JSON file so you don’t lose them the moment you close the terminal. It also shows you your current list, so you can admire how financially responsible you look. No actual money involved—yet.
AI Prompt:
Write a Python program that allows users to input and store multiple stock symbols, display them, and save the list in a JSON file. Make it beginner-friendly.
Functions & Features
- Add a stock symbol to your personal watchlist
- Display your current stock list
- Save everything to a JSON file for future sessions
- Quit the program using a menu option (helpfully numbered 99)
Requirements / Setup
Python 3.8 or higher
No external libraries required (yet). If you’re starting fresh, set up a virtual environment like this:
python -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windows
Minimal Code Sample
def add_stock(symbol):
symbol = symbol.upper()
stocks = load_stocks()
if symbol not in stocks:
stocks.append(symbol)
save_stocks(stocks)
Adds a new stock symbol to the list and saves it—simple, clean, effective.
Notes / Lessons Learned
I meant to start this two or three weeks ago, but I blinked and suddenly forgot how to create a virtual environment. My brain filed it somewhere between “how to fold a fitted sheet” and “useful Latin phrases.” After some desperate Googling, I finally got it working and documented it—this time for real. No more fumbling with pip and hoping for the best.
Since I want my little tracker to actually remember the stocks I add, I set it up to save everything in a JSON file. I also made the menu option to quit the program number 99. Why? Because it looks dramatic, and it guarantees it’ll always show up at the end of the menu. Will this strategy work? Unclear. Will I pretend I did it on purpose even if it doesn’t? Absolutely.
I enthusiastically added all the stock tickers I wanted to follow… and of course, I immediately typed one in wrong. Which means tomorrow’s task is obvious: build a delete function so I can pretend that the mistake never happened.
Optional Ideas for Expansion
- Let users add a nickname or note next to each stock (e.g., “my retirement bet”)
- Validate stock symbols against a real financial API to catch typos early
- Add timestamps to track when each stock was added
