title: How to solve risk parity allocation using Python
body: <p>I would like to solve risk parity problem using python.</p>
  
  <p>Risk parity is a classic approach for portfolio construction in finance. The basic idea is to make sure the risk contribution for each asset is equal.</p>
  
  <p>For example, suppose there're 3 assets, and the co-variance matrix for the asset returns is known:</p>
  
  <pre><code>(var_11,var_12,var_13
  
  var_12,var_22,var_23
  
  var_13,var_23,var_33) 
  </code></pre>
  
  <p>I'd like to come up with a portfolio weight for these assets (w1,w2,w3) so that:</p>
  
  <pre><code>w1+w2+w3=1
  
  w1&gt;=0
  w2&gt;=0
  w3&gt;=0
  </code></pre>
  
  <p>and the risk contribution for each asset equals:</p>
  
  <pre><code>w1^2*var_11+w1*w2*var_12+w1*w3*var_13
  
  =w2^2*var_22+w1*w2*var_12+w2*w3*var_23
  
  =w3^2*var_33+w1*w3*var_13+w2*w3*var_23
  </code></pre>
  
  <p>I am not sure how to solve these equations using python, anyone could shed some light on this?</p>