I Built a Tool That Reads Today's Financial News and Tells You What the Market Thinks
How I Built a Financial News Sentiment Analyzer with RAG and GPT
If you asked GPT right now what the market thinks about Tesla, it would give you an answer based on data from months ago. It has no idea what happened this morning, last week, or even last month. That's the problem I wanted to solve.
The idea
I wanted to build a tool that could answer one simple question: what does the market think about this company right now, based on today's news? Not historical data. Not general knowledge. Real, current news, analyzed intelligently. The result is a Financial News Sentiment Analyzer. You type a company name, and in under 30 seconds you get a structured analysis: overall sentiment (Bullish, Bearish, or Neutral), key themes from recent coverage, a brief summary, and a confidence level based on article quality.
Why GPT alone isn't enough
GPT is incredibly powerful but it has a hard cutoff date. It doesn't know what happened after its training ended. So if you ask it about Apple's sentiment today, it might reference news from a year ago without even realizing it. This is where RAG comes in.
RAG stands for Retrieval Augmented Generation. The idea is simple: instead of relying on what the model already knows, you fetch fresh external information and hand it to the model as context. The model then reasons over that fresh data rather than its old training.
Think of it like this. Think of it like a research assistant. Instead of answering from memory, they go find the most relevant current information first, bring it back to you, and then give you their analysis based on what they just read. RAG is exactly that, retrieve first, then generate.
How it actually works
Here's the full pipeline:
You type "Tesla" into the app. The app calls NewsAPI and fetches the 10 most recent English language articles about Tesla. Each article gets split into smaller chunks of around 500 characters. Each chunk gets converted into a vector, a list of hundreds of numbers that represents its meaning mathematically.
This is where it gets interesting. Words and sentences that mean similar things end up with similar vectors, even if the actual words are completely different. "Tesla shares are rising" and "Tesla stock is gaining value" will have nearly identical vectors because the model understands meaning, not just keywords.
All these vectors get stored in a FAISS database, a tool built by Facebook specifically for fast similarity search across large collections of vectors.
When you ask about sentiment, your question also gets converted into a vector. FAISS finds the 5 chunks whose vectors are closest to your question, the most semantically relevant pieces of text. Those 5 chunks get sent to GPT along with a prompt that says: you are a financial analyst, here is recent news context, analyze the sentiment. GPT reads those chunks and returns structured analysis. The whole process takes under 30 seconds.
What I built it with
Python, LangChain, OpenAI GPT-3.5-turbo, FAISS, Streamlit, and NewsAPI. The frontend is a clean Streamlit interface with a sidebar for settings and a two-column results layout showing the analysis on the left and the source articles on the right.
What broke along the way
LangChain updates its package structure frequently and several imports that worked six months ago no longer exist in the same location. I ran into three separate ModuleNotFoundError issues just from import paths changing between versions. The fix each time was the same: read the error carefully, find the new location, update the import. But it taught me something important - always check which version of LangChain you're using and read the migration docs before starting a new project.
The other issue was data quality. NewsAPI occasionally returns incomplete articles with missing fields. Without defensive coding - checking that each article is actually a dictionary with the expected keys before processing it, the pipeline would crash on bad data. Real world data is always messier than tutorial data.
What I'd improve
A few things I'd add with more time: caching so the same company doesn't re-fetch articles on every run, a sentiment trend chart showing how sentiment has changed over the past week, and support for comparing two companies side by side.
Try it yourself
The app is live and free to use. Type in any company name and see what the market is saying right now.
Live demo: https://naumenko-analytics-financial-sentiment-analyzer.streamlit.app/
The full code is on GitHub if you want to dig into the implementation.
GitHub: https://github.com/naumenko-analytics/financial-sentiment-analyzer