DIY – Stock trader

The COVID pandemic is still not over… and my social life is crumbling like a cookie soaked in hot tea. So what to do about it? Well… sitting in my coding dungeon and starting a new project called “Stonks”!

Stonks in action

“Stonks” will fetch the current stock value every x seconds for a certain ticker. When the stock value of the current day is positive the lights in my room will turn green. If the value drops negative the lights will turn red!

Now I can enjoy life while knowing instantly when I lose all my money! I already nicknamed my room “the red room”.

Also a disclaimer, I used fake data for this demo. It’s after closing hours and the market is not that volatile. But I have a working copy for myself

A few folks have asked how I set things up, and how I did it, so I figured I would write about it!

Setting up the Light

The obvious step to make this all work is to go ahead and buy a smart strip light. At least buy one that has an API that you can use to control the light. I used the Philips Hue Lightstrip.

I placed it right under a shelf and above my desk. It looks nice and dandy.

Philips Hue Strip

Controlling the Light

I started a new project in my IDE, thinking I should start with the hardest part and that is to control the lights. I knew I wanted to make the app in Flutter since it’s a great way to make multiplatform applications. And… who am I kidding, I know that a friend of mine already made a flutter package which is a wrapper around the Hue API.

So I implemented the package and followed the steps to control the light strip in my coding dungeon.

Give the man a thumbs up if you like the package!

Fetching the Stonks

The first step is done, now I should search for a free API that provides stock data. After trying out some providers I ended up using Finnhub. It provided two endpoints that I needed.


Get real-time quote data for US stocks.


Get candlestick data (OHLCV) for stocks.

After fetching the data, it was all about the right UI elements. I found a pretty-looking charts package for flutter and decided to use that to show the closing numbers of the last 60 days. It worked out well!


After writing some logic to change the lights to a certain color depending on the stock trading number, the app was already done! I knew I wanted to share this with the world so I grabbed my camera, created scenery, and started filming… but nothing happened.

Apparently, stock markets are closed on the weekends and they are not that volatile that the lights will jump to a different color every second. Not that exciting video! So I created some fake data to simulate what the app could do.

Fake data

End Result

Add a Comment

Your email address will not be published.