DIY Python Stock Tracker

Stock Portfolio

I’m into playing the stock market and like to watch how my stock prices bounce around. But keeping track of everything is a pain in the ass. Most tools out there either want too much money, looks like they were designed by country music fans, or want to blackmail me with photos. I like to keep my data in my control, so I needed something better to keep track of my investments.

So, what did I do? I tossed together an interesting Python script that talks to a stock market API and throws the info up on a Grafana dashboard. It’s pretty neat. You can check out what it looks like below, and if you’re curious, grab the full code right here.

Stock Portfolio

This thing works with a .csv file that has all my stock transactions - what I bought, for how much, and how many shares. Every morning, There’s a helper script, transform.py, that gets all that data dressed and ready for the main event.

I’m using the no-cost plan on tiingo.com for grabbing stock data, which means they put a cap on how often I can hit their server for updates. So, I’m stuck refreshing my whole portfolio only a few times a day. Your mileage may vary depending on how much you plan on tracking.

Stock Portfolio

After the script gets the data, it stuffs it into an SQLite database and then onto a Grafana dashboard to visualize. It’s all running on a tiny server hiding in a closet somewhere. It’s a pretty convenient setup that doesn’t cost anything or try to know everything about me.

Previous: Ronin Next: Custom PacMan Phone Case