Insights
Normalize Wikipedia Attention for Stock Research
Alphanume Team · July 28, 2026
Normalize Wikipedia attention by comparing each ticker's daily page views with its own trailing 30-day baseline, then test attention surprises against matched events instead of comparing raw traffic across companies.
Alphanume Wikipedia Views supplies one row per ticker and date with views, avg_30d, and zscore_30d. Raw page views describe how many visits the mapped company page received. The z-score describes how unusual that count was relative to the same ticker's recent distribution.
This is the practical normalization step. A mega-cap company can have more page traffic on an ordinary day than a small company has during a major event. Comparing raw counts mostly ranks persistent popularity. Comparing each name with its own baseline measures surprise on a common scale.
Read the attention contract
Field | Meaning | Research treatment |
|---|---|---|
ticker | Equity symbol mapped to a page | Join with the mapped page name |
name | Wikipedia page associated with the ticker | Audit mapping changes and ambiguous companies |
views | Daily page-view count | Raw attention level |
avg_30d | Trailing 30-day mean | Local popularity baseline |
zscore_30d | Distance from trailing distribution in standard deviations | Attention surprise, not sentiment |
A high z-score says attention was unusually high. It does not reveal whether readers were bullish, bearish, curious, or researching a non-market story. A takeover rumor, product announcement, data breach, executive scandal, and school assignment can all generate page views.
The 30-day baseline adapts quickly. A company that stays in the news for several weeks can show a modest z-score even while absolute views remain elevated because the story has entered its recent normal. Preserve both raw and normalized fields.
Pull selected tickers and keep every page
The endpoint accepts ticker, exact date or date ranges, and z-score filters such as zscore_30d_gte. Results use keyset pagination ordered by date descending and ticker ascending. Copy both cursor_date and cursor_ticker from next_cursor until has_more is false.
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 = {"ticker": "AAPL", "date_gte": "2025-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)For a cross-sectional anomaly screen, set one exact date and a z-score threshold, then page the full response. For a small selected universe, per-ticker pulls make mapping and missing-date audits easier. Save the raw pages before filtering event windows.
Audit the normalization before using it
Audit | Comparison | Failure it catches |
|---|---|---|
Served mean | avg_30d versus mean of prior 30 observations | Wrong inclusion or window length |
Served z-score | zscore_30d versus locally reconstructed value | Current-row leakage or scale mismatch |
Page identity | ticker and name through time | Mapping changes and ambiguous companies |
Warmup | Prior observation count | Partially formed baselines |
Cross-name scale | Raw views versus z-score ranks | Persistent popularity mistaken for surprise |
Reconstruct the baseline for a small ticker sample before using the served z-score in a larger study. The production window uses the prior 30 observations, excluding the current day. A ticker with data gaps can therefore span more than 30 calendar days. Keep the prior-row count and the earliest date inside each reconstructed window.
Compare raw-view and z-score rankings on several dates. Large companies should dominate many raw-count lists, while the normalized list should surface names far from their own baseline. Investigate disagreements through the mapped page, baseline mean, baseline standard deviation, and missing observations rather than treating the served score as an unexplained label.
A later signal test should freeze its z-score threshold before returns are loaded and keep attention as a continuous feature beside threshold buckets. The separate Wikipedia attention signal test owns event matching, placebo dates, and incremental predictive evidence.
Normalization still has failure modes
- Page mapping. One ticker maps to one page, while a company can be discussed across product, founder, or parent-company pages.
- Audience mix. Readers include journalists, students, customers, and accidental visitors as well as investors.
- Adaptive baseline. A long-running story raises its own 30-day mean and compresses later z-scores.
- Event contamination. Control dates can contain unrecorded news, earnings, or corporate actions.
- Direction gap. Attention intensity contains no positive or negative sentiment label.
Free access covers a trailing 20-trading-session delayed window. That is enough to inspect fields but too short for a full baseline-plus-event panel, so historical tests need full access.
Run one normalization audit
Choose 20 to 50 tickers and export daily views, served means, served z-scores, page names, and missing observations. Reconstruct the prior-30-observation mean and standard deviation, compare the local and served scores, and publish every mismatch with its window dates and row count. Then compare one raw-view ranking with its z-score ranking to show exactly what normalization changes.
Explore mappings and filters on the Wikipedia Views page and reproduce the cursor contract from the Wikipedia Views documentation. Treat the result as a validated attention measurement. Causation, sentiment, and return prediction belong to a later research design.