Stock Portfolio Monitor on a TV With a Raspberry Pi Zero W

by renovatio-diy in Circuits > Raspberry Pi

82 Views, 0 Favorites, 0 Comments

Stock Portfolio Monitor on a TV With a Raspberry Pi Zero W

IMG_20261009_111134~2.jpg

A Raspberry Pi Zero W (or any Linux SBC) plugged into a TV's HDMI port shows a self-refreshing table of stock prices, daily change, and gain or loss against purchase price. Data comes from the Finnhub API free tier; the software is a single C program running on the Linux text console.. Portfolio apps and websites have to be opened to be read. This display stays on a screen that is already in the room. The Zero W is the cheapest Raspberry Pi with Wi-Fi and HDMI, and a text console needs no more than it has.

Hobby project, not financial advice. See the Disclaimer at the end.

Supplies

  1. Any Raspberry Pi or Linux SBC with HDMI and WiFi/Ethernet
  2. Power Supply
  3. Micro SD Card with OS installed
  4. HDMI Cable

Get a Finnhub API Key

Register at https://finnhub.io/ and copy the API key from the dashboard. Treat it as a password.

Build the Software

The software builds on any Linux-based single-board computer with a C compiler, CMake and OpenSSL headers, for example a Raspberry Pi Zero W running Raspberry Pi OS (formerly Raspbian). The commands below are for Debian-based systems such as Raspberry Pi OS; other distributions use their own package manager.

sudo apt update
sudo apt install -y git build-essential cmake libssl-dev
git clone --recurse-submodules https://github.com/renovatio-systems/finnhub-stock-tracker.git
cd finnhub-stock-tracker
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build


Add the API Key and Tickers

IMG_20261009_110650.jpg
IMG_20261009_111125~2.jpg


mkdir ~/stock-monitor
cd ~/stock-monitor
nano api.txt

Paste the API key, save (Ctrl+O, Enter), exit (Ctrl+X). If api is missing, you will see a message like above. Then:

chmod 600 api.txt
nano tickers.txt

One holding per line: symbol, price paid per share, number of shares.

AAPL,150.00,10
MSFT,450.00,5
GOOGL,120.00,8

Run it once:

~/finnhub-stock-tracker/build/stock_monitor

Check: a table prints with one row per ticker.

Run It on the TV at Boot

A systemd service shows the monitor on the TV in place of the login prompt and refreshes every 60 seconds.

Create the service file:

sudo nano /etc/systemd/system/stock-monitor.service

Paste the following, replacing <user> in three places with your username (run whoami if unsure). Save (Ctrl+O, Enter) and exit (Ctrl+X).

[Unit]
Description=Stock monitor on HDMI console
After=network-online.target
Wants=network-online.target
Conflicts=getty@tty1.service
After=getty@tty1.service

[Service]
User=<user>
WorkingDirectory=/home/<user>/stock-monitor
ExecStart=/home/<user>/finnhub-stock-tracker/build/stock_monitor tickers.txt --watch 60
StandardInput=tty
StandardOutput=tty
StandardError=journal
TTYPath=/dev/tty1
TTYReset=yes
TTYVHangup=yes
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

Stop the screen from blanking, enable the service, and reboot:

sudo sed -i '1 s/$/ consoleblank=0/' /boot/firmware/cmdline.txt
sudo systemctl enable stock-monitor
sudo reboot

Each refresh uses 2 API calls per ticker. Free Tier offers 60 API calls/minute.

To change tickers later, edit ~/stock-monitor/tickers.txt and run sudo systemctl restart stock-monitor.

Check: after the reboot, the table appears on the TV.

Disclaimer

This is a hobby project, built for personal use and shared for educational purposes only. It is not financial advice and not a trading tool.

  1. Prices, changes and gain/loss figures may be delayed, incomplete or wrong. They depend on a third-party data provider (Finnhub) and on the limitations listed above. Do not rely on them for investment or trading decisions. Check figures with your broker or another authoritative source.
  2. The software is provided "as is", without warranty of any kind, under the MIT License. The author accepts no liability for any loss, damage or cost arising from its use, including financial loss, missed trades, data errors or hardware damage.
  3. You are responsible for complying with Finnhub's terms of service and for keeping your API key secure.

Limitations

  1. US stocks only, on Finnhub's free tier.
  2. No currency conversion.
  3. If a stock's price can't be fetched, it is left out of the table until the next refresh.
  4. ETFs such as SPY show "Unknown" as the company name, because Finnhub has no company profile for them.
  5. The table flickers briefly when it refreshes.