A production-ready Raspberry Pi portfolio tracker that displays live stock and cryptocurrency prices on a Waveshare 2.7-inch e-ink display and provides a full web configuration dashboard.
| Category | Details |
|---|---|
| Display | Waveshare 2.7" e-ink, 176ร264, 4-level greyscale |
| Assets | Stocks (yfinance), Crypto (CoinGecko), Forex/ETFs |
| Portfolio | Buy-in price, quantity, current value, P&L in $ and % |
| Pages | All assets ยท Crypto only ยท Stocks only ยท Summary |
| Web UI | Responsive dashboard, dark/light theme, live preview |
| Alerts | Telegram notifications on configurable P&L thresholds |
| Data | SQLite + price history, in-memory cache |
| Service | systemd, auto-start on boot, watchdog restart |
pi-stock-ticker/
โโโ backend/
โ โโโ main.py โ FastAPI app, startup/shutdown
โ โโโ config.py โ Pydantic settings (.env driven)
โ โโโ database.py โ SQLAlchemy + SQLite (WAL mode)
โ โโโ models.py โ Asset, Setting, PriceHistory ORM
โ โโโ price_fetcher.py โ CoinGecko + yfinance + cache
โ โโโ portfolio.py โ P&L calculation, price update
โ โโโ scheduler.py โ APScheduler jobs
โ โโโ eink_renderer.py โ Pillow-based image renderer
โ โโโ display_controller.pyโ Waveshare wrapper + mock mode
โ โโโ telegram_bot.py โ Optional price alerts
โ โโโ routes/
โ โโโ assets.py โ CRUD /api/assets/*
โ โโโ settings.py โ /api/settings/
โ โโโ display.py โ /api/display/preview*, /refresh
โโโ frontend/
โ โโโ index.html โ SPA shell
โ โโโ style.css โ Dark/light theme CSS
โ โโโ app.js โ Vanilla-JS controller
โโโ waveshare/
โ โโโ epd2in7.py โ Official Waveshare driver (adapted)
โ โโโ epdconfig.py โ GPIO/SPI pin config
โโโ systemd/
โ โโโ pi-stock-ticker.service
โโโ scripts/
โ โโโ install.sh โ Full installer
โ โโโ dev.sh โ Desktop/dev run (mock display)
โโโ fonts/ โ DejaVu Mono (copied by installer)
โโโ data/ โ portfolio.db (created at runtime)
โโโ logs/ โ app.log, service.log
โโโ requirements.txt
โโโ .env.example
The Waveshare 2.7" HAT plugs directly onto the 40-pin GPIO header.
If you need to wire manually:
| HAT pin | BCM GPIO | Function |
|---|---|---|
| RST | 17 | Reset |
| DC | 25 | Data/Command select |
| CS | 8 (CE0) | SPI chip select |
| BUSY | 24 | Busy signal (input) |
| CLK | 11 (SCLK) | SPI clock |
| DIN | 10 (MOSI) | SPI data |
| VCC | 3.3 V | Power |
| GND | GND | Ground |
git clone https://github.com/youruser/pi-stock-ticker.git
cd pi-stock-ticker
bash scripts/install.sh
The installer will:
- Install system packages and Python dependencies
- Enable the SPI interface
- Copy DejaVu Mono fonts
- Create a .env from .env.example
- Register and enable the systemd service
nano .env
Key settings:
REFRESH_INTERVAL=300 # price fetch every 5 minutes
DISPLAY_CURRENCY=USD
DISPLAY_ROTATION=true # rotate pages automatically
PAGE_DURATION=15 # seconds per page
# Optional Telegram alerts
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
sudo systemctl start pi-stock-ticker
sudo systemctl status pi-stock-ticker
http://<raspberry-pi-ip>:8000
Find your Pi's IP with: hostname -I
No Raspberry Pi? Run with a mock display on any machine:
# Create venv and install deps
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Run with mock display (no GPIO needed)
bash scripts/dev.sh
Open http://localhost:8000 โ the display preview will render in the browser.
This page โ also accessible at /readme โ rendered from README.md.
Interactive docs: http://<pi>:8000/api/docs
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/assets/ |
List all assets |
POST |
/api/assets/ |
Create asset |
PUT |
/api/assets/{id} |
Update asset |
DELETE |
/api/assets/{id} |
Delete asset |
GET |
/api/assets/search/crypto?q= |
Search CoinGecko |
GET |
/api/assets/search/stock?q= |
Search Yahoo Finance |
GET |
/api/display/preview.png?page= |
E-ink PNG (all/crypto/stocks/summary) |
GET |
/api/display/preview?page= |
Base64-encoded preview |
GET |
/api/display/summary |
Portfolio totals + asset list |
POST |
/api/display/refresh |
Force price fetch |
POST |
/api/display/clear |
Clear physical display |
GET |
/api/settings/ |
Get settings (secrets masked) |
PUT |
/api/settings/ |
Update settings |
| Variable | Default | Description |
|---|---|---|
HOST |
0.0.0.0 |
Bind address |
PORT |
8000 |
HTTP port |
DEBUG |
false |
Enable debug logging + hot reload |
REFRESH_INTERVAL |
300 |
Seconds between price fetches |
DISPLAY_CURRENCY |
USD |
Portfolio currency |
DISPLAY_ROTATION |
true |
Auto-rotate display pages |
PAGE_DURATION |
15 |
Seconds per display page |
DISPLAY_ENABLED |
true |
Enable e-ink output |
DISPLAY_MOCK |
false |
Suppress hardware calls |
COINGECKO_API_KEY |
`` | CoinGecko Pro key (optional) |
ALPHA_VANTAGE_KEY |
`` | Alpha Vantage key (optional) |
TELEGRAM_BOT_TOKEN |
`` | Telegram bot token |
TELEGRAM_CHAT_ID |
`` | Telegram chat/user ID |
TELEGRAM_ALERT_THRESHOLD |
5.0 |
Alert when |P&L%| โฅ this value |
@BotFather on Telegram โ /newbot โ copy the token@userinfobot โ copy your user ID (or use a group chat ID)TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID in .env or the Settings tabTELEGRAM_ALERT_THRESHOLD| Page | Content |
|---|---|
| All | Full portfolio โ all assets, P&L per row, total in footer |
| Crypto | Crypto assets only with sub-total |
| Stocks | Stock/forex assets only with sub-total |
| Summary | Total value, P&L, best/worst performers, last-updated timestamp |
Pages rotate automatically every PAGE_DURATION seconds when DISPLAY_ROTATION=true.
A full e-ink refresh is forced every 10 partial updates to prevent ghosting.
| Resource | Typical usage |
|---|---|
| RAM | ~60โ90 MB |
| CPU idle | < 1 % |
| CPU during price fetch | 10โ20 % (a few seconds) |
| Disk (SQLite) | < 50 MB after a year of history |
The service is capped at 256 MB RAM and 80 % CPU by the systemd unit.
# Check SPI is enabled
ls /dev/spi*
# Enable SPI if missing
sudo raspi-config nonint do_spi 0
sudo reboot
# Check logs
journalctl -u pi-stock-ticker -f
# yfinance needs internet
curl -s https://finance.yahoo.com | head -5
# CoinGecko free tier: 30 req/min
# Increase REFRESH_INTERVAL if you see 429 errors
# Check status
sudo systemctl status pi-stock-ticker
# Re-read service file after editing
sudo systemctl daemon-reload
sudo systemctl restart pi-stock-ticker
# Copy DejaVu fonts manually
cp /usr/share/fonts/truetype/dejavu/DejaVuSansMono*.ttf fonts/
cd pi-stock-ticker
git pull
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart pi-stock-ticker
MIT โ free to use, modify, and distribute.
Built for Raspberry Pi + Waveshare 2.7" e-Paper HAT.
Web UI readable at /readme on any running instance.