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
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
- Any Raspberry Pi or Linux SBC with HDMI and WiFi/Ethernet
- Power Supply
- Micro SD Card with OS installed
- 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.
Add the API Key and Tickers
Paste the API key, save (Ctrl+O, Enter), exit (Ctrl+X). If api is missing, you will see a message like above. Then:
One holding per line: symbol, price paid per share, number of shares.
Run it once:
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:
Paste the following, replacing <user> in three places with your username (run whoami if unsure). Save (Ctrl+O, Enter) and exit (Ctrl+X).
Stop the screen from blanking, enable the service, and 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.
- 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.
- 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.
- You are responsible for complying with Finnhub's terms of service and for keeping your API key secure.
Limitations
- US stocks only, on Finnhub's free tier.
- No currency conversion.
- If a stock's price can't be fetched, it is left out of the table until the next refresh.
- ETFs such as SPY show "Unknown" as the company name, because Finnhub has no company profile for them.
- The table flickers briefly when it refreshes.