Return Concentration
Calculate the concentration of the returns of an investment portfolio or asset, as López de Prado measures a strategy’s bets: how much of the gains come from a few returns, how much of the losses do, and how much the returns cluster in a few months. Each is a normalized Herfindahl-Hirschman Index between 0, where every return contributes the same, and 1, where one return holds everything. A strategy whose gains rest on a handful of days is more fragile than one that earns them steadily, even with the same total.
The formula is as follows:
\[h = \frac{\text{SUM} w_{j}^{2} - \frac{1}{N}}{1 - \frac{1}{N}},\;\; \text{with}\;\; w_{j} = \frac{x_{j}}{\text{SUM} x} \;\text{over}\; N \;\text{values}\] \[\text{Positive Concentration} = h \;\text{of the returns of 0 or more}\] \[\text{Negative Concentration} = h \;\text{of the returns below}\; 0\] \[\text{Time Concentration} = h \;\text{of the number of returns in each calendar month}\]Also known as: bets concentration, HHI of returns, Herfindahl-Hirschman Index of returns.
Example · AAPL, MSFT, KO · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_return_concentration:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "KO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_return_concentration()
Or, with the Finance Toolkit MCP set up, ask an AI assistant such as Claude or ChatGPT:
How concentrated were the gains and losses of Apple, Microsoft and Coca-Cola in a few days from 2021 to 2025?
Which returns:
| Item | AAPL | MSFT | KO |
|---|---|---|---|
| Positive Concentration | 0.0015 | 0.0014 | 0.0012 |
| Negative Concentration | 0.0015 | 0.0015 | 0.0015 |
| Time Concentration | 0.0001 | 0.0001 | 0.0001 |
3 rows
Parameters
get_return_concentration accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period of the returns over the whole history, or with within_period=True the period the daily returns are grouped by. Options are: “daily”, “weekly”, “monthly”, “quarterly”, “yearly”. Defaults to “daily”, or with within_period=True to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "weekly" |
within_period | bool | Whether to calculate the concentration from the daily returns within each period (e.g. each year if period = ‘yearly’) instead of from the returns of period over the whole history. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
References
- Paper López de Prado, M. (2018). “Advances in Financial Machine Learning.” Wiley, section 14.5.1 (Snippet 14.3).
- Paper Herfindahl, O.C. (1950). “Concentration in the Steel Industry.” Columbia University.