Automating My Stock Analysis: From Slow Grind to Time Saver

Published by

on

Last weekend, I dove back into stock analysis. I quickly realized something. It was going to take forever to go through each of the 500 stocks I wanted to review. For each stock, I had to filter the historical data. Then, I had to copy and paste it into a spreadsheet. Finally, I had to extract the information I needed (check out my last post for details on my scoring system). Once I had the data, I would analyze it. After analyzing it, I would score it. Finally, I would add it to my tracker to compare stocks. It was a slow and manual process.

Since, I use a Mac so I couldn’t use Microsoft Excel’s VBA feature to create a macro. This prevented me from speeding up the process. I was feeling stuck, wondering if I had to continue this slow grind forever. Then, a light bulb went off!

I remembered that I had a book on Python, a programming language that could help me automate the process. But I wasn’t sure if it would work on my Mac since I only switched from Windows two years ago. Flipping through the book, I was relieved to see that it was Mac-friendly. I quickly downloaded all the software. It, of course, took longer than expected. Then I wrote my first simple Python program. Success! There was hope.

However, as I continued reading, I realized automating the entire process would take time. Writing the code to handle every step wasn’t going to be quick. I found myself at another roadblock. Should I just evaluate one stock at a time and work on the program little by little? It was progress, but still way too slow.

Then, I had another idea.

Yup, ChatGPT to the rescue! Step by step, I asked ChatGPT to help me write the Python code for each part of the process. I would run the script, and if it worked, I moved on to the next step. If it didn’t, ChatGPT would help me fix it. If ChatGPT couldn’t, luckily, I knew enough Python to debug the rest. After about 4 ½ hours, we had created a program. The program took the historic stock data and pulled out everything I needed to calculate the scores. This was a huge time saver!

But my brain didn’t stop there. Could I automate even more? Could I program it to score the stocks once I had the data? I decided to figure that out on Sunday.

On Sunday morning, after finishing my usual routine, I jumped right back into it. I started thinking about how I make scoring decisions and wondered if I could turn those decisions into numbers. For most things, it was pretty easy. For example, if the dividend percentage is above a certain level, I could give it 5 points. But what about the direction of the dividend? It was easy for me to look at the numbers and tell if they were flat. I could see if the numbers were increasing, decreasing, or all over the place. But how do I calculate that? I worked through each score this way, figuring out how to represent my decisions with math.

After that, I went back to writing the program. I added in new categories and adjusted some of the criteria. I realized I’d missed a few important details. It’s fun to think about this stuff, but it’s also challenging. If you’re not careful, you can make expensive mistakes.

Here’s how the process works now:

  1. I look up a stock and paste the historic data into a spreadsheet.
  2. The program:
    • Pulls out all the data I’m interested in and organizes it.
    • Evaluates the data, calculates a score, and gives me a summary of the stock.
    • Creates a folder with the stock symbol, saves the data, and the evaluation.
  3. I copy the summary into my comparison spreadsheet and move on to the next stock.

What used to take 20 minutes per stock now takes just 3 minutes. What a time saver!

Now, I just need to run this for the remaining 500 stocks and compare them. I currently hold 3 stocks that are doing well in their own way. Scoring them will help me compare them to the other stocks. But it’s still early. I know I’ll come across scenarios that will break my automation. These scenarios may also make me rethink my process. Still, I’d say this was a pretty successful weekend in my stock investing journey.

Until next time, happy investing!

Leave a comment