Workflow

Daily WSB Sentiment Analysis Pipeline

Automated daily sentiment analysis of r/wallstreetbets and r/stocks. Extract ticker mentions, score sentiment, detect momentum spikes.

Overview

This pipeline runs every morning before market open to analyze Reddit trading subreddits for ticker mentions and sentiment signals. It queries Scavio Reddit endpoint for r/wallstreetbets and r/stocks discussions, extracts ticker symbols, counts mention frequency, and compares against a 7-day rolling average to detect momentum spikes. Output is a ranked signal feed sorted by mention spike magnitude.

Trigger

Cron schedule (daily at 8:00 AM EST, before market open)

Schedule

Runs daily at 8:00 AM EST before market open

Workflow Steps

1

Query Reddit trading subreddits

Search Scavio Reddit endpoint for recent posts from r/wallstreetbets, r/stocks, and r/options.

2

Extract ticker symbols

Parse post titles and snippets for uppercase ticker patterns, filtering out common English words.

3

Count mention frequency

Tally mentions per ticker and compare against the 7-day rolling average from previous runs.

4

Score sentiment per ticker

Classify post context as bullish, bearish, or neutral based on keyword patterns in snippets.

5

Generate ranked signal feed

Sort tickers by mention spike magnitude and output a ranked JSON feed with sentiment scores.

Python Implementation

Python
import requests
import json
import re
from collections import Counter
from datetime import datetime
from pathlib import Path

API_KEY = "your_scavio_api_key"
TICKER_RE = re.compile(r"\b[A-Z]{2,5}\b")
SKIP_WORDS = {"THE","AND","FOR","ARE","BUT","NOT","YOU","ALL","CAN","HAS","HER","WAS","ONE","OUR","OUT","HIS","HOW","ITS","MAY","NEW","NOW","OLD","SEE","WAY","WHO","DID","GET","HIM","LET","SAY","SHE","TOO","USE","WSB","IMO","TBH","YOLO","FOMO","HODL"}

BULLISH = {"bull","moon","buy","calls","long","squeeze","rocket","tendies","gain","pump"}
BEARISH = {"bear","puts","short","crash","dump","sell","tank","loss","drill","rug"}

def scan_subreddit(query: str) -> list[dict]:
    res = requests.post(
        "https://api.scavio.dev/api/v1/search",
        headers={"x-api-key": API_KEY},
        json={"platform": "reddit", "query": query},
        timeout=15,
    )
    res.raise_for_status()
    return res.json().get("organic", [])

def extract_signals(posts: list[dict]) -> dict:
    ticker_counts = Counter()
    ticker_sentiment = {}
    for post in posts:
        text = f"{post.get('title', '')} {post.get('snippet', '')}"
        tickers = [t for t in TICKER_RE.findall(text) if t not in SKIP_WORDS]
        words = set(text.lower().split())
        bull_score = len(words & BULLISH)
        bear_score = len(words & BEARISH)
        sentiment = "bullish" if bull_score > bear_score else "bearish" if bear_score > bull_score else "neutral"
        for t in tickers:
            ticker_counts[t] += 1
            if t not in ticker_sentiment:
                ticker_sentiment[t] = {"bullish": 0, "bearish": 0, "neutral": 0}
            ticker_sentiment[t][sentiment] += 1
    return {"counts": ticker_counts, "sentiment": ticker_sentiment}

def run():
    date = datetime.utcnow().strftime("%Y-%m-%d")
    all_posts = []
    for query in ["wallstreetbets today", "stocks trading today", "options plays today"]:
        all_posts.extend(scan_subreddit(query))

    signals = extract_signals(all_posts)
    top_tickers = signals["counts"].most_common(15)

    feed = {
        "date": date,
        "posts_scanned": len(all_posts),
        "signals": [
            {"ticker": t, "mentions": c, "sentiment": signals["sentiment"].get(t, {})}
            for t, c in top_tickers
        ],
    }

    Path(f"wsb_signals_{date}.json").write_text(json.dumps(feed, indent=2))
    print(f"WSB signal scan {date}: {len(all_posts)} posts, {len(top_tickers)} tickers")
    for t, c in top_tickers[:5]:
        s = signals["sentiment"].get(t, {})
        print(f"  ${t}: {c} mentions (bull:{s.get('bullish',0)} bear:{s.get('bearish',0)})")

if __name__ == "__main__":
    run()

JavaScript Implementation

JavaScript
const API_KEY = "your_scavio_api_key";
const SKIP = new Set(["THE","AND","FOR","ARE","BUT","NOT","YOU","ALL","CAN","HAS","WSB","IMO","YOLO","FOMO"]);
const BULL = new Set(["bull","moon","buy","calls","long","squeeze","gain"]);
const BEAR = new Set(["bear","puts","short","crash","dump","sell","loss"]);

async function scanReddit(query) {
  const res = await fetch("https://api.scavio.dev/api/v1/search", {
    method: "POST",
    headers: { "x-api-key": API_KEY, "content-type": "application/json" },
    body: JSON.stringify({ platform: "reddit", query }),
  });
  return (await res.json()).organic ?? [];
}

const posts = [];
for (const q of ["wallstreetbets today", "stocks trading today"]) posts.push(...await scanReddit(q));
const counts = {};
for (const p of posts) {
  const text = `${p.title ?? ""} ${p.snippet ?? ""}`;
  for (const m of text.matchAll(/\b[A-Z]{2,5}\b/g)) {
    if (!SKIP.has(m[0])) counts[m[0]] = (counts[m[0]] ?? 0) + 1;
  }
}
const top = Object.entries(counts).sort((a, b) => b[1] - a[1]).slice(0, 10);
top.forEach(([t, c]) => console.log(`$${t}: ${c} mentions`));

Platforms Used

Reddit

Community, posts & threaded comments from any subreddit

Frequently Asked Questions

This pipeline runs every morning before market open to analyze Reddit trading subreddits for ticker mentions and sentiment signals. It queries Scavio Reddit endpoint for r/wallstreetbets and r/stocks discussions, extracts ticker symbols, counts mention frequency, and compares against a 7-day rolling average to detect momentum spikes. Output is a ranked signal feed sorted by mention spike magnitude.

This workflow uses a cron schedule (daily at 8:00 am est, before market open). Runs daily at 8:00 AM EST before market open.

This workflow uses the following Scavio platforms: reddit. Each platform is called via the same unified API endpoint.

Yes. Scavio's free tier includes 250 credits per month with no credit card required. That is enough to test and validate this workflow before scaling it.

Daily WSB Sentiment Analysis Pipeline

Automated daily sentiment analysis of r/wallstreetbets and r/stocks. Extract ticker mentions, score sentiment, detect momentum spikes.