X/Twitter Sentiment Scanner
Real-time social sentiment analysis for stock tickers using Grok models via OpenRouter.
Architecture
Multi-stage pipeline inspired by xAI's Filtered Stream guide:
- •Collect — Pull real-time X/Twitter posts about stock tickers (via Grok's native X access)
- •Filter (Fast) — Batch posts →
grok-4classifies signal vs noise (spam, memes, irrelevant) - •Score (Deep) — High-signal posts →
grok-3-minifor deep sentiment reasoning (bullish/bearish/neutral, 0-100) - •Rolling Update — Each new signal post triggers sentiment recalculation
Why Multi-Stage?
- •Fast model (
grok-4) handles high throughput filtering cheaply - •Reasoning model (
grok-3-mini) only processes quality signal posts - •Cost-efficient: ~80% of posts are noise, filtered before expensive reasoning
Models (via OpenRouter)
| Model | Role | Speed | Cost |
|---|---|---|---|
x-ai/grok-4 | Fast classification/filtering | Fast | Low |
x-ai/grok-3-mini-beta | Deep sentiment scoring + reasoning | Medium | Medium |
x-ai/grok-4.1-fast | Alternative fast model | Fastest | Lowest |
Scripts
scripts/grok-sentiment-scanner.sh
Single-ticker or multi-ticker sentiment scanner.
bash
./grok-sentiment-scanner.sh AAPL TSLA WOLF
Output per ticker (/data/sentiment-{TICKER}.json):
json
{
"ticker": "AAPL",
"sentiment": "bullish",
"score": 78,
"signal_posts": 12,
"key_themes": ["earnings beat", "AI growth"],
"timestamp": "2025-07-25T14:30:00Z"
}
scripts/batch-sentiment.sh
Wrapper for watchlist tickers. Writes combined output to /data/sentiment-state.json.
Environment
- •
OPENROUTER_API_KEY— Required (set in env or hardcoded in scripts)
Agent
PULSE runs this skill on a 2-hour cron during market hours (Mon-Fri 12-21 UTC).
Data Files
- •
/data/sentiment-{TICKER}.json— Per-ticker sentiment - •
/data/sentiment-state.json— Combined watchlist sentiment state