I don’t obsess over day-to-day movements in the stock market, but I do like to know what’s happening in the world when there’s volatility. I built a low-power stock market information radiator to stay informed passively, rather than searching or scrolling.
The Raspberry Pi Zero is perfect for small projects like this. It runs Linux, so we can write software with high-level languages and iterate quickly. Yet, it’s not much bigger than a micro-controller and consumes less than 1W of power when idle. E-ink is a good fit here because it only draws power when updating, and the matte screen minimises distraction. Let’s walk through the build.
Hardware
We’re going to assemble the Raspberry Pi with a couple of components from Pimoroni, most importantly the e-ink display itself.
Physical assembly
Here’s the bill of materials:
- Raspberry Pi Zero 2 with GPIO header
- Pimoroni Inky pHAT (black/white or black/white/red)
- Pimoroni LED SHIM
- MicroSD card
- Micro-USB power supply
It comes to roughly £40 in total. To assemble, we just slide the LED SHIM over the top row of GPIO pins and then firmly seat the Inky pHAT on top. Once we have all three pieces in place, it’s time to get the system up and running.
System setup
-
Use the Raspberry Pi Imager to flash the MicroSD card with the headless “Lite” OS. We don’t need a desktop environment, since the e-ink panel is our display and it gets updated via the GPIO interface. There are a few crucial steps in the Imager:
- Add credentials for a 2.4GHz Wi-Fi access point (Pi Zero models do not support 5GHz)
- Set up a username, password, and hostname
- Enable SSH
-
Mount the MicroSD card in the Raspberry Pi and power it up
-
Log in to the Raspberry Pi via SSH from your terminal, using the credentials provided in the first step
ssh pi@raspberrypi.local -
Update the system
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y -
Install Git, which we’ll use to fetch the software in the next steps
sudo apt install git
At this point the Raspberry Pi itself is ready to go and we just need to configure the extra components we’ve added.
Display and LED setup
- Follow the LED SHIM install guide and Inky pHAT install guide. Make sure you allow the install script to create the Python virtual environment at
~/.virtualenvs/pimoroni/bin/activate. - Reboot the system to ensure the new hardware is recognised
We can test the components are installed correctly by running example scripts from the setup guides. Once we have something displaying on the e-ink display and LEDs lit up, we’re ready to move on to the software.
Software
The software is a Python script that fetches today’s stock performance from the Yahoo Finance API and renders a 250x122 pixel image that can be written to the e-ink panel. The LED bar will glow green or red depending on whether the symbol is up or down. You can find the source code on GitHub.
Log in to the Raspberry Pi via SSH to clone the repository and install the additional dependencies:
git clone https://github.com/jdamcd/inky-stocks.git
cd inky-stocks
source ~/.virtualenvs/pimoroni/bin/activate
pip install -r requirements.txt
Configuration
The script can be set to track any symbol available in the Yahoo Finance API, meaning it supports any individual stock, index, or major cryptocurrency. There’s no API key required. You can simply add the symbol you want to track as a parameter, or it’ll default to ^GSPC (the S&P 500 index). For example, if you want to track Apple Inc.:
python stocks.py --symbol AAPL
If you have a variant of the Inky pHAT that supports red ink, you can add the --three-color parameter and the trend line will be highlighted in red when it drops below the opening price.
Automatic refresh
We can use a cron job to run the script and update the display periodically. 15 minutes is a decent cadence for a low-power accessory that’s designed to be observed passively.
-
Let’s first wrap the command in a bash script to ensure the Python environment is activated. This way there’s no extra setup required when the device boots – it’ll just start updating on the specified schedule.
touch run.sh && chmod +x run.sh nano run.sh -
Add your desired configuration to this file:
#!/bin/bash source ~/.virtualenvs/pimoroni/bin/activate python ~/inky-stocks/stocks.py --symbol ^GSPC --three-color -
Run
crontab -eand add the following line to execute the script every 15 minutes:*/15 * * * * ~/inky-stocks/run.sh
Note that you won’t see any changes out of trading hours unless you’re tracking a 24/7 symbol like Bitcoin. If the market has just opened, the script will graph the end of the previous day so you can see the trend.
The finished product
I wanted this to feel like a complete object, so I also designed a case that sits the display at a nice viewing angle on a desk. If you have access to a 3D printer, the model is published on MakerWorld.
There are a few extra components required for this step:
- Translucent filament to allow the LED bar to shine through
- Micro-USB panel mount extension cable
- 4x M2.5 screws
I printed mine in a combination of black and clear PETG. It looks great with the top of the enclosure glowing red or green.
Conclusion
This project is a bit of fun – nobody is making financial decisions based on handmade gizmos. However, I hope it sparks some ideas and shows that it’s quite easy to start building custom projects with a handful of off-the-shelf components.
As for next steps, I just got my hands on the much larger 4.2" Inky wHAT panel so I’m already dreaming up the next project.