# Using News Sentiment as a Trading Signal in Algorithmic Trading
Algorithmic trading on cryptocurrency markets loses effectiveness when indicators ignore shifts in market regime. The solution is analyzing news sentiment through vector search and RAG models, rather than LLM interpretations. This lets you catch fundamental sentiment shifts before they show up in price.
Why Traditional Indicators Stop Working
Moving averages and RSI are calibrated on historical data, assuming a stable market regime. But reality involves alternating bearish and bullish days, often flipping within a single day. Technical analysis doesn't adapt to these switches because it's built on averaging. A positive news story in the morning, negative in the evening. As a result, indicators show "noise" instead of trends.
The problem isn't the tools—it's the context of their use. Indicators work within a regime but don't identify the regime itself. News backdrop sets the regime—how authoritative sources shape market participants' perceptions.
How to Properly Collect and Filter News
Building a signal isn't just about parsing headlines. Three parameters are critical: domain, publication time, and vector similarity. Here's how to do it:
- Use vector search instead of keywords
- Leverage PgVector or MongoDB Atlas Vector Search for semantic search, not word matching.
- Look for near-zero scores on cosine similarity—they capture hidden influences (e.g., mentions of Trump without direct Bitcoin references).
- Skip LLMs for initial search—they interpret rather than capture raw sentiment.
- Focus on authoritative domains
- SEC regulatory docs don't move markets on their own—only when reposted by influential bloggers or analysts.
- Build a whitelist of domains whose audiences actually sway retail investors.
- Account for timing
- Daily averaging kills directionality. Use a strict 24-hour window—enough to filter noise while preserving context.
- Filter out publications with unknown times (e.g., 00:00:00 GMT). They introduce look-ahead bias.
Practical Implementation: Code and Filtering
When working with APIs like Tavily, handle timestamps correctly. Here's a JavaScript filtering example:
const hour = dayjs(publishedDate).utc().get("hour");
const minute = dayjs(publishedDate).utc().get("minute");
if (hour === 0 && minute === 0) {
console.warn(`fetchNews search invalid publishedDate query=${query} url=${url} from=${from} to=${to}`)
return false;
}
Also, query data for -2 days back, then filter the last 24 hours locally. This fixes lost publications at day boundaries due to CDN and database quirks.
Case Studies: How Sentiment Precedes Price Moves
In two real cases, a vector search-based system correctly identified the direction:
- Neutral-bearish sentiment → subsequent BTC price drop.
- Bullish sentiment → steady rise over the next hours.
Key point: the system doesn't predict price. It captures the synergistic effect of many publications shaping collective market expectations. Those expectations then materialize in chart movements.
Position Management: Exit on PnL, Not Sentiment
Exiting trades on sentiment shifts is too late. Parsers lag, and you lose profits. The optimal approach: take profits on a 3% pullback from the max PnL of an open position.
Example: if a position hits +10%, exit at +7%. This locks in 97% of gains, even if news hasn't shifted yet. Over 10 trades, this can boost total returns by up to +30%.
For risk management, use hard stop-losses and trailing take-profits. They protect against sudden reversals that even the fastest news systems miss.
Key Takeaways
- Separate vector search from LLMs: the first finds sentiment, the second interprets it.
- 24-hour window is optimal: shorter adds noise, longer loses direction.
- Authoritative domains > regulators: markets react to interpretations, not facts.
- Exit on PnL, not signals: saves 3% per winning trade.
- Filter timeless publications: they skew backtests.
— Editorial Team
No comments yet.