AgentSkillsCN

X Sentiment Scanner

X 情绪扫描仪

SKILL.md

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:

  1. Collect — Pull real-time X/Twitter posts about stock tickers (via Grok's native X access)
  2. Filter (Fast) — Batch posts → grok-4 classifies signal vs noise (spam, memes, irrelevant)
  3. Score (Deep) — High-signal posts → grok-3-mini for deep sentiment reasoning (bullish/bearish/neutral, 0-100)
  4. 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)

ModelRoleSpeedCost
x-ai/grok-4Fast classification/filteringFastLow
x-ai/grok-3-mini-betaDeep sentiment scoring + reasoningMediumMedium
x-ai/grok-4.1-fastAlternative fast modelFastestLowest

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