Two stocks can sit side by side on a heat ranking with exactly the same mention count and still have very different stories behind them. One might be mentioned once each by forty different institutions and influencers. The other might be mentioned ten times each by four. A leaderboard sorted by mentions cannot tell them apart.
This post walks through a small derived metric that can: mentions per agency (mpa). It works on any heat dataset that reports both a raw mention count and a distinct-source count, and it is especially useful when you build quant research features on top of an institution and KOL heat monitor such as Lava. All numbers below are illustrative.
The Two Counters Behind Every Heat Row
Most rows in Lava's heat endpoints carry two integers measured over the same interval:
| Field | What it counts | Deduplication |
|---|---|---|
mentions |
Number of times the stock was mentioned | None. Repeated mentions by one source are counted each time |
agencies |
Number of distinct institutions / influencers that mentioned it | Deduplicated by anonymous agency_id
|
The interval depends on the endpoint. Market-wide rankings (/hot/stocks) use a rolling window such as 24h or 7d. Concept-level views (/concepts/stocks, /concepts/by-stock) use a days lookback. The daily panel (/panel/daily) slices by calendar day. The ratio is only meaningful when both counters come from the same row, so never mix a mentions value from one endpoint with an agencies value from another.
Defining the Ratio and Its Edge Cases
The definition is deliberately boring:
mpa = mentions / agencies if agencies >= 1
mpa = null if agencies == 0
The edge cases are where most pipelines go wrong:
-
The floor is 1. Every source contributes at least one mention, so
mpa >= 1. A value of exactly 1 means each source spoke once, which is the most dispersed structure possible. -
A zero denominator is null, not zero. Rows with
mentions > 0andagencies == 0can occur when a mention record is not linked to a source. Keep them as null and count them separately. Folding them into either bucket distorts the distribution. -
Small denominators are noise. With
agenciesat 1 or 2, the ratio swings wildly. Set a minimum (we use 5 in the examples) and only readmpaabove it. - Intervals are not interchangeable. A source has more chances to repeat itself over seven days than over twenty-four hours, so long-window ratios drift upward. Fix the window before you compare anything.
-
Use the log for cross-sections.
log(mpa)compresses outliers, and zero maps neatly to "one mention per source".
Four Discussion Structures
Combine the cross-sectional percentile of mentions with mpa, and every row falls into one of four quadrants:
| Mentions percentile | mpa |
Structure | What to look at next |
|---|---|---|---|
| High | Low (about 1–2) | Broad: many sources, each mentioning once | Concept links via /concepts/by-stock
|
| High | High | Concentrated: a few sources repeating themselves | Sample agency_id distribution in /opinions
|
| Low | High | Niche: small volume from a small group | Usually logged, rarely interpreted alone |
| Low | Low | Scattered | First-mention events often land here |
A worked example from one 24h window: stock A has mentions=48, agencies=40, so mpa=1.2. Stock B has mentions=48, agencies=6, so mpa=8.0. On the ranking they look like twins. In reality, B's count is far more sensitive to the posting habits of a single source.
Building the Feature from a Daily Panel
The daily panel returns mentions, agencies, weighted_heat and is_first_mention_day per stock per calendar day, up to 20 codes and 92 days per request. The script below batches a universe, computes mpa, and tags each row with a quadrant.
# mpa_panel.py - illustrative; base URL and token are placeholders
import os
import numpy as np
import pandas as pd
import requests
BASE = os.environ.get("LAVA_BASE", "<YOUR_LAVA_BASE>/subscribe/v1")
HEADERS = {"Authorization": "Bearer " + os.environ.get("LAVA_API_KEY", "<YOUR_TOKEN>")}
MIN_AGENCIES = 5 # example threshold
BATCH = 20 # panel limit per request
def fetch_panel(codes, start, end):
resp = requests.get(
BASE + "/panel/daily",
params={"type": "stock", "codes": ",".join(codes), "from": start, "to": end},
headers=HEADERS, timeout=60,
).json()
assert resp["ok"], resp["code"]
data = resp["data"]
rows = data if isinstance(data, list) else data.get("list", [])
df = pd.DataFrame(rows)
df["request_id"] = resp["meta"]["request_id"]
return df
universe = ["<CODE_1>", "<CODE_2>"] # your own universe
panel = pd.concat(
[fetch_panel(universe[i:i + BATCH], "2026-10-01", "2026-11-13")
for i in range(0, len(universe), BATCH)],
ignore_index=True,
)
# Column names (date, ts_code) should be checked against the OpenAPI schema.
eligible = panel["agencies"].where(panel["agencies"] >= MIN_AGENCIES)
panel["mpa"] = panel["mentions"] / eligible
panel["log_mpa"] = np.log(panel["mpa"])
panel["m_pct"] = panel.groupby("date")["mentions"].rank(pct=True)
panel["mpa_pct"] = panel.groupby("date")["log_mpa"].rank(pct=True)
panel["quadrant"] = np.select(
[
(panel["m_pct"] >= 0.8) & (panel["mpa_pct"] >= 0.8),
(panel["m_pct"] >= 0.8),
(panel["mpa_pct"] >= 0.8),
],
["high/concentrated", "high/broad", "low/concentrated"],
default="low/scattered",
)
panel.loc[panel["mpa"].isna(), "quadrant"] = "insufficient_sources"
print(panel["quadrant"].value_counts())
Two engineering details deserve attention.
Calendar days versus trading days. The panel includes weekends and holidays. If you align it with trading-day market data, decide first where weekend counts go, sum the raw counters, and only then divide. Averaging two daily ratios is not the same as the ratio of two sums.
Multi-day aggregation. Summing agencies across days double-counts any source that appears on more than one day. For a seven-day view, request a seven-day window directly instead of summing seven daily rows.
How mpa Relates to Other Heat Metrics
mpa answers one narrow question: is the discussion spread out or concentrated? It says nothing about who is talking. Pair it with:
| Metric | Endpoint | Question it answers |
|---|---|---|
weighted_heat |
/panel/daily, /hot/weighted
|
How much heat after weighting each source by its score |
cov_7d, cov_30d
|
/coverage/stocks |
Distinct sources over a rolling 7 / 30 days, a steadier denominator |
new_cov_cum |
/coverage/stocks |
Cumulative newly covering sources; new entrants usually pull mpa down |
high_score_ratio_30d |
/coverage/stocks |
Share of high-score sources over 30 days |
One caveat for backtests: weighted_heat on the daily panel uses current source scores, not point-in-time scores. For strict historical work, use the as_of_date parameter on /hot/weighted or the /agencies/pit snapshot.
A Logging Checklist
- Always record the endpoint and interval with the value, for example "
/hot/stocks,window=24h". - Applying
min_scoreto/hot/stocksshrinks both counters, so the ratio becomes "concentration among high-score sources". Label it that way. - Do not mix
market=allrankings (merged by name) withmarket=asharerankings (merged by code) in one cross-section. - Persist
meta.server_time,meta.request_id, both raw counters and the computedmpa.
FAQ
Does a high mpa mean low-quality discussion?
No. It describes how mentions are distributed across sources and is independent of source scores. Use weighted_heat or high_score_ratio_30d for quality questions.
Can I compute it for concepts?
Yes. /hot/concepts and /concepts/stocks return both counters, and the interpretation carries over directly.
Why do the ranking and the daily panel give different ratios for the same stock?
Different intervals. The 24h ranking rolls back from meta.server_time; the panel cuts at calendar-day boundaries. Both are correct for their own interval.
Wrapping Up
mentions tells you how often a stock was discussed; agencies tells you by how many distinct voices. Dividing one by the other turns a flat ranking into a picture of discussion structure. Fix the interval, enforce a minimum source count, keep nulls as nulls, and the ratio becomes a stable, explainable feature for quant research.
Field definitions and the read-only monitoring views are documented on the Lava research page.
中文简介:本文介绍如何用「提及次数 ÷ 机构/大V 数」(mentions per agency)区分同等热度下的广泛讨论与少数主体集中讨论。文中给出分母为 0、小样本、跨窗口不可比等边界规则,以及从日频面板取数并分档的 Python 示例。熔岩是量化交易必备的机构/大V 热度监测工具。
Top comments (0)