💸 Stocktrix: Smarter Way to Read Financial News
Source code: https://github.com/Harshish/stocktrix
Welcome to Stocktrix, a tiny web app I built because I got tired of manually reading stock news and guessing whether the market was feeling happy, sad, or mildly confused. Humans are unreliable; algorithms, on the other hand, are reliably chaotic... but at least they're fast.
My mission was simple: 👉 Feed it fresh stock news 👉 Get a sentiment prediction 👉 Hope it tells me something useful before I make irresponsible financial decisions
For this adventure, I used FastAPI for the backend and Next.js for the frontend because nothing screams "I totally know what I'm doing" like a Python-React combo.
Backend: FastAPI
Before I could analyze anything, FastAPI had to fetch news about a company. Easy, right? HAHAHA. No.
I explored three options:
1. Paid APIs like NewsAPI
Pros: Excellent filtering! Cons: My wallet filed an official complaint.
2. Free APIs like Yahoo Finance
Pros: Free (my favorite price). Cons: News only from the last 24 hours, i.e., just enough to know that something happened but not what.
3. Scraping a financial news site
Pros: Total control! Cons: Dark pattern captchas, HTML nightmares, and websites acting like bouncers at a club ("Cookies enabled? Show me your ID.") + legaly gray area.
Eventually, I settled on the Yahoo Finance API because: - It's free 🙌 - It includes article summaries - And if the project ever blows up (manifesting ✨), I can swap to a paid API
For scraped articles, I needed summaries. So I tried using an open-source text summarizer from Hugging Face, which... worked. Slowly. Very slowly. Summarizing 10-15 articles in one go felt like waiting for GTA6 to release. Overall, a poor UX.
The Sentiment Model
DistilBERT Walked So GPT Could Run
This was all pre-LLM hype, so I dug through Hugging Face and found the KernAI distilbert-news-sentiment model. A solid choice:
- It was lightweight 🪽
- It hit ~85-90% accuracy 🎯
- It didn't require a GPU powered by the sun 🌞
Link for fellow nerds: https://huggingface.co/KernAI/stock-news-distilbert
API Security
At some point, I remembered that leaving API endpoints open to the world is "generally frowned upon." I thought about adding JWT. Then I remembered JWT needed Redis sessions. Then I remembered I was lazy.
Solution? A simple API key stored in .env. Boom. Secure enough for a personal project and 90% less headache.
Frontend: Next.js
For the UI, I used:
- Next.js for SSR and good SEO
- TailwindCSS because writing CSS makes my soul leave my body
- Self-hosted Umami for analytics, because I don't trust Google watching my every click
The result was clean, fast, and surprisingly non-ugly.
Deployment (or: "How I Launched a Startup for the Price of a Sandwich")
I bought a domain from Namecheap, spun up a VM on Hetzner, and deployed the whole thing with Docker Compose.
One git push later... ✨ stocktrix.online was born ✨
I was like a proud parent, but for a website that still doesn't pay rent.
Then I self-hosted Coolify, hooked it to GitHub, and set up automatic deploys. Coolify is an open source and free to use platform that allows you to self-host your services with ease. It also has a discount if you use Hetzner servers ✌️ More info - https://coolify.io/docs/
Cool Next Steps
(aka Features I Will Definitely Build... Soon™)
- Replace DistilBERT with an LLM because accuracy is the new sexy
- Turn the frontend into a PWA
- Add a database for historical sentiment because charts = credibility
- Add user auth so people can store favorite stocks
- Push notifications when sentiment changes dramatically ("Sell sell sell!")