Concentration and Diffusion
5 algorithms in Market Breadth and Internals · 5 with asserted arithmetic.
In this family#
-
Top-N Index Contribution verified
How much of an index's move came from its largest N members. This is the arithmetic behind 'seven stocks are holding up the market' — a claim that is usually asserted and rarely measured.
calculate(rows, topN) -
Herfindahl Constituent Concentration verified
The Herfindahl–Hirschman index of constituent weights: the sum of squared weights. Squaring is what makes it a concentration measure — it is dominated by the largest holdings in a way a simple count never is.
calculate(rows) -
Effective Number of Constituents verified
The reciprocal of HHI: how many equally weighted holdings would give the same concentration. An index of 500 names with an effective number of 60 is, for risk purposes, a 60-stock portfolio.
calculate(rows) -
Sector Diffusion Index verified
The share of sectors improving rather than deteriorating. Diffusion asks how *broad* a move is across groups, which a capitalisation-weighted index cannot show — one sector can carry the whole level.
calculate(rows, tolerance) -
Factor Diffusion Index verified
The same diffusion measure across factors rather than sectors — momentum, size, volatility — showing whether a move is broad across styles or concentrated in one.
calculate(rows, tolerance)
What they share#
Every topic here is a record-transform, so once you have
called one the rest follow the same shape. Import paths differ only in the final segment:
import { calculate } from "fintech-algorithms/market-breadth-and-internals/concentration-and-diffusion/top-n-index-contribution";
import { calculate } from "fintech-algorithms/market-breadth-and-internals/concentration-and-diffusion/herfindahl-constituent-concentration";Read them in the order above — the sequence is pedagogical, not alphabetical.
Where this sits#
Market Breadth and Internals collects 28 algorithms across 5 families. For the concept behind this family rather than the call signatures, see the concept guides.