Insights
How to Test Wikipedia Attention as a Stock Signal
Alphanume Team · July 22, 2026
Test Wikipedia attention as a stock signal by asking whether page-view surprise adds predictive information after controlling for the news or corporate event that caused people to look.
Alphanume Wikipedia Views maps tickers to company pages and returns daily views, a trailing avg_30d, and zscore_30d. The z-score normalizes each company against its own recent traffic, making an attention spike comparable across names with very different baseline popularity.
The hard part is causality. News can move the stock and send people to Wikipedia on the same day. A raw comparison of high-z-score days with ordinary days can assign the news effect to page views. The useful test compares similar event days with different attention responses, then asks whether attention adds anything beyond the event itself.
Define the signal without adding sentiment
Input | Meaning | Do not infer |
|---|---|---|
views | Absolute daily page traffic | Number of investors or trades |
avg_30d | Recent per-ticker baseline | Long-run normal level |
zscore_30d | Standardized attention surprise | Bullish or bearish sentiment |
name | Mapped Wikipedia page | Complete coverage of every company-related page |
date | Page-view observation date | Exact intraday order of news, views, and price |
Wikipedia traffic is a daily count. It does not reveal whether attention arrived before a filing, after a headline, or after the close. A backtest should attach returns from the next safely tradeable session unless a separate timestamped source establishes earlier availability.
A z-score of 2 means traffic is two standard deviations above that ticker's trailing distribution. It is a convenient threshold, though it remains a research choice that should be frozen before outcomes are inspected.
Pull high-attention and baseline rows
The endpoint can filter one date across tickers with zscore_30d_gte, or return one ticker across a range. Results use keyset pagination with date and ticker. Save all raw pages and the page mapping because a changed or ambiguous mapping can look like a sudden signal break.
import os
import requests
import pandas as pd
url = "https://api.alphanume.com/v1/wikipedia-views"
headers = {"X-API-Key": os.environ["ALPHANUME_API_KEY"]}
params = {"date_gte": "2024-01-01", "date_lte": "2025-12-31"}
rows = []
while True:
response = requests.get(url, headers=headers, params=params, timeout=30)
response.raise_for_status()
payload = response.json()
rows.extend(payload["data"])
if not payload.get("has_more"):
break
cursor = payload["next_cursor"]
params.update({"cursor_date": cursor["date"], "cursor_ticker": cursor["ticker"]})
attention = pd.DataFrame(rows)
attention["high_attention"] = attention["zscore_30d"] >= 2Free access covers a trailing 20-session delayed window, which is too short for a broad signal test and its event controls. Use full history for the experiment, and keep access errors distinct from missing traffic.
Match the event before testing returns
Treatment row | Matched control | Reason |
|---|---|---|
High-z earnings date | Same earnings timing and similar surprise with ordinary z-score | Controls the scheduled catalyst |
High-z filing date | Same form or event category with ordinary z-score | Controls the disclosure type |
High-z non-event date | Same ticker and weekday with no recorded event | Tests attention outside the known calendar |
Missing attention | Separate cell | Avoids selecting only clean page mappings |
Create event categories from an independent source, then freeze high-attention and control pairs before loading returns. Match by ticker where possible, weekday, market-cap range, prior return, and event type. Report failed matches and the number of unique dates because market-wide news creates correlated attention rows.
The incremental test compares the return or volatility difference between high-attention and ordinary-attention observations inside the same event class. A nested model can add zscore_30d after event controls and evaluate performance on a later period. This answers whether attention contributes beyond the headline.
Guard against a story-mining result
- Reverse timing. Price or news can cause Wikipedia traffic during the same calendar day.
- Multiple thresholds. Searching many z-score cutoffs and horizons inflates the best result.
- Adaptive baseline. A long-running story raises its own mean and makes later traffic look ordinary.
- Page ambiguity. Product, founder, lawsuit, or entertainment interest can move the mapped page.
- No sentiment. A high z-score says people looked, without indicating why or which side they favored.
Predeclare the threshold, event categories, tradeable return window, and primary metric. Show event-only, attention-only, and combined specifications, including a held-out test period.
Add a placebo that shifts each attention series to randomly chosen non-event dates within the same ticker and month. The placebo preserves page popularity and broad market conditions while breaking the event alignment. An apparent effect that survives many random shifts may reflect a persistent company trait or return autocorrelation rather than the observed attention spike.
Run one incremental test
Choose one event type, collect at least a year of page-view rows, and export high-z events, ordinary matched events, unmatched records, page mappings, and next-session outcomes. Compare the event-only model with the event-plus-attention model on a later period and report whether the incremental result survives costs and clustered dates.
Explore the raw attention fields on the Wikipedia Views page and reproduce the cursor and z-score filters from the Wikipedia Views documentation.