Risk Parity
Calculate the risk parity weights: the portfolio in which every asset contributes the same share of the volatility, or the share set by a risk budget. Volatile assets get smaller weights, and correlated assets share their risk budget, so no single asset dominates the portfolio’s risk.
The weights solve w_i (Σw)_i / σ_p = b_i σ_p for every asset, found by minimizing the convex function 1/2 w’Σw - Σ b_i ln(w_i) and scaling the result to sum to one.
For more information, see the following papers:
- Maillard, S., Roncalli, T. and Teïletche, J. (2010). “The Properties of Equally Weighted Risk Contribution Portfolios.” The Journal of Portfolio Management, 36(4), 60-70.
- Spinu, F. (2013). “An Algorithm for Computing Risk Parity Weights.” SSRN Working Paper.
Also known as: equal risk contribution, ERC, risk budgeting.
Risk Parity in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_risk_parity_weights 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_risk_parity_weights()
Or, after setting up the Finance Toolkit MCP, ask:
Which weights in Apple, Microsoft, Johnson & Johnson and ExxonMobil gave each stock an equal share of the portfolio risk, based on 2021 to 2025?
Which returns:
| Weight | Expected Return | Volatility | Sharpe Ratio | Risk Contribution | |
|---|---|---|---|---|---|
| AAPL | 0.1786 | 0.1933 | 0.2786 | 0.5727 | 0.25 |
| MSFT | 0.2129 | 0.2017 | 0.2572 | 0.6532 | 0.25 |
| JNJ | 0.3782 | 0.0984 | 0.1673 | 0.3867 | 0.25 |
| XOM | 0.2303 | 0.291 | 0.2702 | 0.9522 | 0.25 |
| Portfolio | 1 | 0.1817 | 0.1452 | 1.0189 | 1 |
Parameters
get_risk_parity_weights accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
risk_budget | dict[str, float] | None | The share of the risk per asset, e.g. {“AAPL”: 0.4, “MSFT”: 0.2, …}; it is scaled to sum to one. Defaults to None, an equal share for every asset. | None, an equal share for every asset |
period | str | The frequency of the returns (daily, weekly, monthly, quarterly or yearly). Defaults to “daily”. | "weekly" |
include_benchmark | bool | Whether to include the benchmark as an asset. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding. | 2 |