A stateful AI system that tries to predict stock prices (using news)
Using daily news sentiment as a signal for next-day stock price movement
ok so what is this?
I built an app called stocksbrew a while back. It sends me a clean little email every morning with AI summaries of news about the stocks I care about (before the market opens).
Then my brain went: yuh but⊠does this news stuff actually mean anything?
Like, if the news around a stock is positive today, is the stock more likely to go up tomorrow? And if yes, is it predictive enough to not just be vibes?
In other words, can I use the daily news summaries to predict if the stock will go up or down before the market actually opens?
what i built (the whole pipeline)
First, what data do I even have?
In StocksBrewâs DB, thereâs a news_summaries table that stores daily summaries for subscribed stocks. Those summaries are produced by a simple 2-step pipeline:
- fetch raw news (NewsAPI + my custom crawler)
- pass the raw news to an LLM (some version of
gemini-flash) â get a daily summary
Now for this project, I extended that pipeline with sentiment:
- input: todayâs summary
- output: a
sentiment_score(numeric, roughly âhow bullish/bearish are the updatesâ)
I could have just told the model âalso output sentiment_scoreâ in the same prompt as the summary, but that felt too naive (and probably inconsistent).
So instead I made a historical_context object and passed it along with todayâs news so the model has some grounding and can be more consistent day-to-day.
The historical_context object contains mainly three things:
- sentiment_scores of the last 5 days
- news_summaries of the last 5 days
- stock_price movement over the last 5 days
My guess was: giving the model a tiny âmemoryâ should make the sentiment score less random. I didnât A/B test it against the naive version though, so thatâs still a âtrust me bro (for now)â assumption.
Once I settled on this, I wrote a script that backfills sentiment scores for recent history (I did ~45 days worth), then used those scores to predict whether price moves up/down the next trading day.
sanity check (does sentiment even move with price?)
Before going full quant-goblin, I did the obvious thing: plot sentiment vs actual movement and see if thereâs any relationship.

Sometimes it looks aligned. Sometimes itâs completely off. So I needed actual metrics, not just âit kinda looks right sometimesâ.
I needed to know answers to things like - how many times did it make the correct predictions, when does it fail, is it better than random guessing?
evaluation (aka âis it better than flipping a coin?â)
So I crunched numbers across different time windows + different ways of turning sentiment into a âpredictionâ.
Important note / not cheating note:
- I only compute these metrics for stocks that have enough samples (I used >5 predictions in the selected window) so a single lucky/unlucky stock doesnât dominate.

What popped out immediately:
- Daily predictions were not great (worse than random in my tests⊠rip).
- But when I use a 3-day rolling average (sentiment + movement), it behaves way nicer â around 1% better than random chance (CRY) in the screenshot above.
This makes sense to me because news is noisy. A 3-day average smooths âone weird headline dayâ and focuses more on sustained sentiment.
fun metric: which stocks âlisten to the newsâ?
Another thing I really enjoyed: ranking stocks by how often sentiment direction matches the next-day movement.
Basically: âwhich tickers are news-driven (at least in this dataset)â vs âwhich tickers just do their own thingâ.

returns tab (comparing strategies)
I also built a Returns tab where I can compare different strategies side-by-side.
First, I vary how I generate the signal:
- Daily signals: trade on todayâs sentiment (no smoothing)
- 3-day rolling average: smoother signals, less headline-noise
- 5-day rolling average: even smoother, slower to react
Then, I vary what universe I trade:
- All stocks: trade everything (more trades, more chaos)
- High accuracy only: only trade stocks where the model historically crosses >50% accuracy (less trades, hopefully less pain)
Finally, for each combo, I simulate a simple long/short rule:
- LONG when rolling-average sentiment is clearly positive (example threshold I used in the UI: (> 0.3))
- SHORT when rolling-average sentiment is clearly negative (example threshold: (< -0.3))
- otherwise: HOLD
And I track basic outcomes like:
- average return per trade
- cumulative return
- number of trades (because some strategies âlook goodâ just because they barely trade)

the âok but would i make money?â part
Now the fun part. Because accuracy is cute, but the real question is:
How much money would you have made if you had invested in the stocks that stocksbrew predicted positively?
So I simulated a super simple long/short strategy using sentiment as a signal over different time windows using the 3-day rolling strategy that we discussed earlier.

what i learned (so far)
- Smoothing (3D / 5D) usually makes the system look less random because it stops overreacting to one-day news spikes.
- Filtering to âhigh accuracy onlyâ can change the story a lot because it basically says: âdonât force it, only trade where this signal has historically behaved.â
This is not financial advice btw, itâs just me turning my newsletter into a mini research lab lol.
Conclusion
Overall: super fun, definitely imperfect, but itâs already taught me a lot about how noisy ânews â priceâ is.
Some things I want to do next (yus, more chaos):
- test different sentiment prompts / compare the naive approach vs historical-context approach properly
- track performance live going forward (not just backfilled history)
- add better baselines (like âalways holdâ, âalways longâ, etc.) so Iâm not cherry-picking
- eventually make it more agentic than âstateful pipeline that outputs a numberâ
But anyways, that's all for now and I'll see you in the next one!