# How to construct a Risk-Parity portfolio?

If I would like to construct a fully invested long-only portfolio with two asset classes (Bonds $B$ and Stocks $S$) based on the concept of risk-parity.

The weights $W$ of my portfolio would then be the following:

Then the weight of the bonds: $$W_B = \textrm{Vol}(S)/[\textrm{Vol(S)}+\textrm{Vol(B)}]$$

and the weights of the stocks $$W_S = 1 - W_B$$

Based on this result, I am going to overweight the low-volatility asset and underweight the high-volatility asset.
My question is: how do I calculate the weights for a portfolio with multiple asset classes, 5 for example, so that each asset class will have the same volatility and contribute the same amount of risk into my portfolio. From historical data I can extract the volatility of each asset class and the correlation between them.

• Can you show us what you tried and define some variables and equations? In its current form the question is off topic IMHO, see the FAQ. – Bob Jansen Mar 22 '12 at 21:35
• You can offset some of the "diversification" (it's diversification only if the numbers hold during high stress periods) by raising the leverage on the low volatility assets. – bill_080 Mar 22 '12 at 22:24
• @Bootvis: I don't think it's OT. But the formatting could certainly be improved. But the subject is non-trivial. – SRKX Mar 23 '12 at 7:10
• It certainly is an interesting topic but the question, as it is now, does not seem to be written by a professional quant. I would edit the question if I had the time. – Bob Jansen Mar 23 '12 at 8:05

Risk Parity is not about "having the same volatility", it is about having each asset contributing in the same way to the portfolio overall volatility.

The volatility of the portfolio is defined as:

$$\sigma(w)=\sqrt{w' \Sigma w}$$

The risk contribution of asset $i$ is computed as follows:

$$\sigma_i(w)= w_i \times \partial_{w_i} \sigma(w)$$

You can then show that:

$$\sigma(w)=\sum_{i=1}^n \sigma_i(w)$$

The vector of the marginal contributions ($\partial_{w_i} \sigma(w)$) is computed as follows:

$$c(w)= \frac{\Sigma w}{\sqrt{w' \Sigma w}}$$

You can then find the solution by running the following optimization:

$$\underset{w}{\arg \min} \sum_{i=1}^N [\frac{\sqrt{w^T \Sigma w}}{N} - w_i \cdot c(w)_i]^2$$ This article contains all the developments you require to understand how the formulas above are derived.

• Can you explain what techniques are needed to run that optimization? – nxstock-trader Mar 28 '12 at 22:09
• You can basically run this through fmincon in MATLAB for example. Not sure what you mean by "techniques". Are you looking for a specific optimization algorithm? – SRKX Mar 28 '12 at 22:13
• I meant what packages/routines to use if I were doing this in R? – nxstock-trader Mar 29 '12 at 1:01
• @nxstock-trader: you should be able to find something on this page. I haven't used R for optimization for a long time. You can ask on Mathematics or Stack Overflow as well. – SRKX Mar 29 '12 at 6:09
• What is the reason that the risk contribution of each asset is defined as its weight times corresponding marginal contribution? It makes sense to me that marginal contribution describes how fast total risk changes if the asset's weight changes a small amount. But partial derivative times weight is not intuitive to me when it's used to describe risk contribution, though noting that the sum (and here it happens to be $\sigma(w)$) is directional derivative in mathematics. Any intuition behind this definition? – Nicholas Dec 7 '16 at 22:21

I am very happy with the following equivalent formulation for the risk budgeting problem (as presented in Bruder, Roncalli, 2012, Managing Risk Exposures using the Risk Budgeting Apporach):

Let $b_i$, $\Sigma_{i=1}^n b_i =1$ be the risk budgets, $y_i$ the unscaled portfolio weights and $S$ the variance covariance matrix and $c$ arbitrary.

$$y^* = \text{arg min}_y \sqrt{y^T S y}, \quad \text{s.t.} \sum_{i=1}^n b_i \ln y_i \geq c, \quad \sum_{i=1}^ny_i=1, \quad y_i \geq 0$$

Now the good thing about this formulation is: It is a quadratic program with convex constraints (assuming $b_i >0$) which is numerically nice. Further more, for numerical implementation one would like to drop the constraint $\sum_{i=1}^ny_i=1$ and manually rescale afterwards $x_i^* = \frac{y_i^*}{\sum_{i=1}^ny_i^*}$. It works better for me than the solution presented in the other answer.

• Yes, this is a more efficient numerical approach I think. I did not use it in my answer because I find it less intuitive. I'd just add to set $b_i = \frac{1}{n} ~ \forall i$ if he wants an ERC... – SRKX Jul 21 '14 at 13:59
• I am having difficulties finding the optimum in Matlab. i keep getting 50% 50%. Any thoughts on what the reason could be? – JohnAndrews Jun 6 '17 at 7:50
• I still struggle with the b ln y constraint. If one want a risk parity portfolio is c then defined as $\sum_{i=1}^n b_i \ln b_i$ where $b_i = 1/n$? – KIC Jun 7 '17 at 14:02
• @JohnAndrews I suggest you try and play around with S a bit more. Try and take, say, S=diag((2,1)) and see if that does the trick. – vanguard2k Jun 8 '17 at 7:12
• @KIC Now, I have to admit that its been a while but I am pretty sure the $c$ was arbitrary. As a result of that, your solution might not sum to one, but after rescaling (as outlined in the answer) everything is fine. – vanguard2k Jun 8 '17 at 7:12

Another approach to construct a risk parity portfolio would be to use the formulation proposed by Spinu [1]: $$\begin{array}{ll} \underset{\mathbf{w}}{\textsf{minimize}} & \frac{1}{2}\mathbf{w}^{T}\Sigma\mathbf{w} - \sum_{i=1}^{N}b_i\log(w_i)\\ \textsf{subject to} & \mathbf{1}^T\mathbf{w}=1. \end{array}$$ where $$\mathbf{w}$$ is the vector of portfolio weights, $$\Sigma$$ is the covariance matrix, and $$b_i, i = 1, 2, ..., N,$$ are the risk budgets.

A robust algorithm to solve the above optimization problem is available in R and Python through the riskParityPortfolio package: https://github.com/dppalomar/riskParityPortfolio.

[1] Florin Spinu, An Algorithm for Computing Risk Parity Weights, 2013. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2297383

Let us intuitively understand the risk parity algorithm. In this algorithm, the important point to consider is it allocates more capital for the assets which has lower risk and less capital to the assets which has higher risks.

For example, consider two assets where the risk of asset1 is 9% and the risk of asset2 is 5%. Then, the amount of capital allocated to asset1 = 1/9 / (1/9 + 1/5) = 35% and amount allocated to asset2 = (1 - 35%) = 65%.

As seen, 65% is allocated to asset2 as it has less risk of 5% compared to asset1 which has the risk of 9%.

You can check that the formula you gave: $$w_B=\frac{\sigma_S}{\sigma_B+\sigma_S}$$ is algebraically equivalent to $$w_B=\frac{1/\sigma_B}{1/\sigma_B+1/\sigma_S}$$. So the result is the same. But the formula in terms of inverses is more intuitive and more general.

To extend this formula to multiple assets (assuming correlations are zero), you can place the inverse of risk of the asset in numerator and sum of the inverse of risk of all assets in the denominator to get the weights.

In this example, the sum of the inverse of risk of all assets is 0.48. The weight for asset1 is 1/9 / 0.48 = 23%.

To understand the derivation of the algorithm and how to introduce non-zero correlations, you can refer to below link: How to understand this Risk Parity Algorithm?