Calculate how diversified a portfolio is, by the concentration of its weights and by how its risk spreads over independent sources.

  • Herfindahl-Hirschman Index: Σ w_i², from 1/N for equal weights to 1 for a single asset.
  • Effective Number of Assets: 1 / Σ w_i², the number of equally weighted assets that would be as concentrated.
  • Diversification Ratio: the weighted average volatility of the assets over the portfolio’s volatility, w’σ / √(w’Σw); one for a single asset, higher as the assets move less together (Choueifaty and Coignard, 2008).
  • Effective Number of Bets: the covariance matrix is split into uncorrelated principal components, p_k is the share of the portfolio’s variance from component k, and the number of bets is exp(-Σ p_k ln p_k): 1 when all risk comes from one source and N when it spreads evenly over all of them (Meucci, 2009). Equal weights in assets that all follow the market are many assets but close to one bet.

For more information, see the following papers:

  • Choueifaty, Y. and Coignard, Y. (2008). “Toward Maximum Diversification.” The Journal of Portfolio Management, 35(1), 40-51.
  • Meucci, A. (2009). “Managing Diversification.” Risk, 22(5), 74-79.

Also known as: concentration, HHI, effective N, ENB, diversification ratio.

Diversification Metrics in Python or via the MCP

Install the Finance Toolkit with:

pip install financetoolkit -U

Then call get_diversification_metrics as shown below.

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["AAPL", "MSFT", "JNJ", "XOM"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2021-01-01",
    end_date="2025-12-31",
)

toolkit.portfolio.get_diversification_metrics(
    weights={"AAPL": 0.4, "MSFT": 0.3, "JNJ": 0.2, "XOM": 0.1}
)

Or, after setting up the Finance Toolkit MCP, ask:

How diversified was a portfolio of 40% Apple, 30% Microsoft, 20% Johnson & Johnson and 10% ExxonMobil from 2021 to 2025, by effective number of assets and of bets?

Which returns:

  Portfolio
Herfindahl-Hirschman Index 0.3
Effective Number of Assets 3.3333
Diversification Ratio 1.343
Effective Number of Bets 1.1298

Parameters

get_diversification_metrics accepts the following parameters.

ParameterTypeDescriptionExample
weightsdict[str, float] | NoneThe weight per asset. Defaults to None, which uses the latest weights of the Portfolio the Toolkit came from, or equal weights.None, which uses the latest weights of the Portfolio the Toolkit came from, or equal weights
periodstrThe frequency of the returns (daily, weekly, monthly, quarterly or yearly). Defaults to “daily”."weekly"
covariancestrThe estimator of the covariance matrix: “sample” (ddof=1), “ledoit_wolf” (towards the scaled identity, Ledoit and Wolf, 2004), “ledoit_wolf_constant_correlation” (towards the average correlation, Ledoit and Wolf, 2004), “ledoit_wolf_single_factor” (towards the covariance that the benchmark as a single factor implies, Ledoit and Wolf, 2003), “oas” (Chen et al., 2010), “semicovariance” (the co-movement below a zero return, Estrada, 2007), “exponential” (recent periods weigh most, RiskMetrics) or “denoised” (the eigenvalues of the correlation matrix that random returns could produce averaged, Laloux et al., 2000). The shrinkage and denoised estimators stabilize the weights when there are many assets compared to the number of periods. Defaults to “sample”."sample"
covariance_spanintThe span in periods of the “exponential” covariance; the weight of a period halves after about span / 2.9 periods. Defaults to 180.180
include_benchmarkboolWhether to include the benchmark as an asset. Defaults to False.True
roundingint | NoneThe number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding.2
Share