📈 Live Stock Ticker for RGB LED Matrix — Raspberry Pi Project | techlogics.net
Build a live NSE/BSE stock ticker on a 64×32 RGB LED matrix using Raspberry Pi and yfinance. Real-time LTP, % change, ₹ change, direction arrow and rain animation. Full Python source, wiring guide and install steps.
# ============================================================
# Live Stock Ticker — 64×32 RGB LED Matrix
# Generated by techlogics.net
# https://techlogics.net/trading/stock-ticker-led.php
# ============================================================
#
# CAUTION: Review this code fully before running on any
# hardware. Verify all pin connections and power requirements
# match YOUR specific components. We are not responsible for
# damage to hardware, fire, or injury resulting from incorrect
# wiring, faulty components, or misuse of this code.
#
# Generated on: 19 Jul 2026
# ============================================================
#!/usr/bin/env python3
"""
Live stock ticker for a 64x32, 5mm-pitch RGB LED matrix panel.
Driven by Adafruit RGB Matrix HAT + RTC on Raspberry Pi.
Pulls real-time quotes from Yahoo Finance via yfinance.
Row 1: stock symbol (blue, centred)
Row 2: LTP in bold pixel font (white) + direction arrow
Row 3: % change and Rs change (green/red/yellow)
"""
import math
import threading
import time
from PIL import Image
from rgbmatrix import RGBMatrix, RGBMatrixOptions
try:
import yfinance as yf
import numpy.rec
import pandas
except ImportError:
yf = None
# ---------------------------------------------------------------------------
# Panel configuration
# ---------------------------------------------------------------------------
COLS, ROWS = 64, 32
HARDWARE_MAPPING = 'adafruit-hat'
GPIO_SLOWDOWN = 3
BRIGHTNESS = 60
ROW_ADDRESS_TYPE = 0
MULTIPLEXING = 1
PWM_BITS = 8
PWM_LSB_NANOSECONDS = 200
# ---------------------------------------------------------------------------
# Stock list — NSE symbols need .NS suffix, BSE symbols need .BO
# ---------------------------------------------------------------------------
STOCKS = [
'RELIANCE.NS',
'TCS.NS',
'INFY.NS',
'HDFCBANK.NS',
'ICICIBANK.NS',
'SBIN.NS',
'TATASTEEL.NS',
'MARUTI.NS',
'MRF.NS',
'BAJFINANCE.NS',
]
# ---------------------------------------------------------------------------
# Timing
# ---------------------------------------------------------------------------
DISPLAY_INTERVAL_SECONDS = 10
DATA_REFRESH_SECONDS = 30
CACHE_MAX_AGE_SECONDS = 120
FETCH_DELAY_SECONDS = 0.6
MAX_RETRIES_PER_SYMBOL = 3
RETRY_BACKOFF_BASE_SECONDS = 2
RATE_LIMIT_COOLDOWN_SECONDS = 60
# ---------------------------------------------------------------------------
# Rain animation
# ---------------------------------------------------------------------------
RAIN_ENABLED = True
RAIN_TRAIL_LEN = 6
# ---------------------------------------------------------------------------
# Colours
# ---------------------------------------------------------------------------
COLOR_UP = (40, 200, 90)
COLOR_DOWN = (235, 55, 55)
COLOR_FLAT = (235, 195, 30)
NO_DATA_COLOR = (150, 150, 150)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
TITLE_COLOR = (70, 140, 255)
# [rest of source retained — fonts, renderers, StockFeed, main]
# Full source: https://techlogics.net/files/stock_ticker_live.py
# ============================================================
# End of generated code — techlogics.net
# Found this useful? Visit https://techlogics.net/trading/stock-ticker-led.php
# for more free CCTV, networking, electronics & finance tools.
#
# Questions or issues? https://techlogics.net/contact.php
# ============================================================
Step 1: Assemble hardware — stack the Adafruit RGB Matrix HAT on your Pi GPIO header, connect the LED matrix HUB75 ribbon cable, and power the panel from a dedicated 5V 4A supply.
Step 2: Install the rpi-rgb-led-matrix library:
git clone https://github.com/hzeller/rpi-rgb-led-matrix.git
cd rpi-rgb-led-matrix/bindings/python
sudo make build-python PYTHON=$(which python3)
sudo make install-python PYTHON=$(which python3)
Step 3: Install Python dependencies:
sudo $(which python3) -m pip install --break-system-packages yfinance pillow
Step 4: Download stock_ticker_live.py, open it and edit the STOCKS list with your preferred NSE/BSE symbols (NSE needs .NS suffix, e.g. WIPRO.NS).
Step 5: Fill in your config values using the form above, then download the customised file.
Step 6: Run as root (required for GPIO):
sudo $(which python3) stock_ticker_live.py
To run on boot, add to /etc/rc.local before exit 0:
sudo $(which python3) /home/admin/stock_ticker_live.py &