Name It and Claim It: Deleting Stocks and Wrestling Filenames

Day 57 of 100 Days Coding Challenge: Python

Yesterday, I made a small typo when entering a stock symbol—just one little slip of the keyboard, and suddenly I’m the proud owner of a fictional stock ticker. Unfortunately, the program didn’t come with an “oops” button, so today’s goal was obvious: build a function that lets me delete stock symbols from my list before my portfolio starts sounding like a toddler named it.

While I was at it, I got curious about filenames. You see, in the past, I’ve gone a bit wild with my naming convention—stuff like Book_Tracker_v2.py, final_final_please_work.py, or the classic version3_newest_final_backup2.py. This time, I wanted to test a more polished approach. I tried naming my file stock_tracker v1.1.py, thinking it looked quite professional. Spoiler alert: Python did not agree. Turns out, spaces in filenames are like pineapple on pizza—technically possible, but likely to cause arguments and strange behavior. Thankfully, stock_tracker_v1.1.py worked like a charm. I even read online that while dashes (-) are allowed, underscores (_) are generally the safer bet, especially if you want to avoid those sneaky bugs that only show up on Tuesdays after coffee.

Today’s Motivation / Challenge

Stock lists, like closets, need regular cleaning. If you accidentally track “TSLAA” instead of “TSLA,” your code won’t yell at you—but your future self will. Today’s challenge was all about giving the user (ahem, me) the power to tidy up their tracked stocks without digging through JSON files manually. It’s about building habits—and menus—that you can live with.

Purpose of the Code (Object)

This code lets you remove any stock symbol you’ve previously added. You just type the ticker you no longer want, and poof—it’s gone from the list. No editing files, no drama. The script also includes the option to view your list or exit gracefully (with a nod of thanks).

AI Prompt:

Write a Python program that allows users to delete a stock symbol from a JSON-based watchlist. The program should prevent duplicates, validate user input, and display a clean menu.

Functions & Features

  • Add new stock symbols to your list
  • View all currently tracked stocks
  • Remove a stock symbol by name
  • Quit the program (option 99, always last)

Requirements / Setup

Python 3.8 or higher

No additional libraries are needed. If you’re starting from scratch, create a virtual environment:

python -m venv venv

source venv/bin/activate  # macOS/Linux

venv\Scripts\activate     # Windows

Minimal Code Sample

def remove_stock(symbol):

    symbol = symbol.upper()

    stocks = load_stocks()

    if symbol in stocks:

        stocks.remove(symbol)

        save_stocks(stocks)

Removes a stock from your tracked list if it exists.

Stock Tracker

Notes / Lessons Learned

The trusty “Exit” option is still holding strong at number 99—right where it belongs. Tucking it at the bottom of the menu means no more accidental goodbyes when all I meant to do was clean up a typo. It’s like the emergency exit: always there, but hopefully not pressed by mistake.

Now, about filenames. I had this grand idea to name my script stock_tracker v1.1.py—you know, a classy versioning system worthy of a Silicon Valley pitch deck. Python, however, wasn’t impressed. Turns out, putting spaces in filenames is a little like trying to run a sprint in flip-flops. Technically doable. Practically… a terrible idea. After a few errors and some Googling, I landed on stock_tracker_v1_1.py, which behaved much better. Pro tip: underscores are your friends, hyphens are moody, and spaces are just asking for trouble.

Oh, and that rogue stock symbol I entered yesterday? Gone. Deleted. Justice served.

Optional Ideas for Expansion

  • Confirm before deleting a stock (a simple “Are you sure?” prompt)
  • Add auto-complete for stock symbols already in the list
  • Show a “last modified” timestamp next to each symbol

Stocks, Aristotle, and Other Risky Investments

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.

Stock Tracker

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