# How to derive portfolio weights from risk budget

Goal: I'm trying to frame target volatility investments given some view on what asset to overweight. For example, starting with a risk-parity allocation, tweak the marginal risk contribution of each asset (all equals in risk-parity) and derive the corresponding target weights of the portfolio.

Example: you want to invest in 3 assets. You are given the risk budget for each stock [0.5, 0.3, 0.2]. The goal is to derive the portfolio weights such that the marginal contribution of each asset to the variance of the portfolio is explained by respectively 50%, 30% and 20% for each asset. The goal is to find the portfolio weights $$\mathbf{w} \in \mathbb{R}^3$$ such that the target vol of the portfolio is $$v \in \mathbb{R}^+$$.

Question: what the relevant literature on portfolio construction from risk budgeting? A necessary condition for the answer is to provide references. Some python code which solves the example above for a given correlation matrix would be appreciated.

• See the paper by Roncalli Managing Risk Exposures using the Risk Budgeting Approach. With only 3 stocks you don't even need Python, you can do it in Excel in 15 minutes from start to finish. – Alex C Jul 2 '19 at 15:05

What you want is to design a risk budgeting portfolio. If your constraints are only $$\mathbf{1}^T\mathbf{w}=1$$ and $$\mathbf{w} \geq \mathbf{0}$$, then the correct way to do it is to use the formulation proposed by Spinu : $$\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.

I've implemented a solver for that optimization problem in both R and Python. The code is open source, you can check out the documentations at: https://github.com/dppalomar/riskParityPortfolio (R version) and https://github.com/dppalomar/riskparity.py (Python version).

As a code snippet, you can do it in one line of Python code:

import riskparityportfolio as rp
optimum_weights = rp.vanilla.design(cov, np.array([0.5, 0.3, 0.2]))


where cov is the covariance matrix of your assets.

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