Diversification
Diversification is the reduction of risk that comes from spreading an investment over assets that do not move in step. When one asset falls, another may hold up or rise, so the value of the portfolio swings less than the average of its holdings. Markowitz (1952) made this precise: the risk of a portfolio depends not only on the risk of each asset but on how the assets move together, so adding an asset with a low correlation can lower the risk of a portfolio without lowering its expected return.
The formula for the variance of a portfolio is as follows:
\[\text{Portfolio Variance} = \sum_{i=1}^{N} \sum_{j=1}^{N} w_{i} \cdot w_{j} \cdot \sigma_{i} \cdot \sigma_{j} \cdot \rho_{\text{ij}}\]Where \(w_{i}\) is the weight of asset i, \(\sigma_{i}\) its volatility and \(\rho_{ij}\) the correlation between assets i and j. With a correlation below 1, the volatility of the portfolio is below the weighted average of the volatilities.
Diversification removes the risk that is specific to each company but not the risk all assets share. Evans and Archer (1968) found that most of the specific risk of a portfolio of US stocks is gone with about ten randomly chosen stocks, after which the risk levels off at that of the market. Correlations also rise in a crisis, when diversification is needed most, so a portfolio that looks diversified in calm markets can be less so in a sell-off.
The Finance Toolkit measures how diversified a portfolio is with the diversification metrics: the Herfindahl-Hirschman index and the effective number of assets for the concentration of the weights, and the diversification ratio of Choueifaty and Coignard (2008) and the effective number of bets for how the risk spreads over independent sources. The correlation matrix shows how the assets move together, and the maximum diversification, risk parity and efficient frontier portfolios build the weights from it.
Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then:
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})
Which returns:
| Item | Portfolio |
|---|---|
| Herfindahl-Hirschman Index | 0.3 |
| Effective Number of Assets | 3.3333 |
| Diversification Ratio | 1.3432 |
| Effective Number of Bets | 1.1299 |
References
- Paper Markowitz, H. (1952). “Portfolio Selection.” The Journal of Finance, 7(1), 77-91.
- Paper Evans, J.L. & Archer, S.H. (1968). “Diversification and the Reduction of Dispersion: An Empirical Analysis.” The Journal of Finance, 23(5), 761-767.
- Paper Choueifaty, Y. & Coignard, Y. (2008). “Toward Maximum Diversification.” The Journal of Portfolio Management, 35(1), 40-51.