Say I have a portfolio of stocks, stock A, stock B and stock C, with the below positions:

  • stock A: long 100 USD
  • stock B: long 50 USD
  • stock C: short 200 USD

How do I calculate the portfolio variance given the covariance matrix?

I guess this question boils down to: how do I obtain the weights for each stock?

If I divide the value of each position by the net portfolio value (-50 USD) so that the weights sum to 1 then I get [-2, -1, 4] which makes no sense since I now have negative weights for long positions and positive weights for short positions.

If I introduce a 4th asset, a risk-less cash component, of which I am long 51 USD then I have weights [100, 50, -200, 51]. Great, the weights sum to 1 and are the correct sign, however [10, 5, -20, 6] would be an equally valid weights vector but would give a completely difference variance when multiplied out with the covariance matrix.

So what's the correct way to obtain the weights for each asset in this portfolio and thus what's the correct way to calculate the portfolio variance?


1 Answer 1


I think your are really asking how to normalize the weights. For example,

$$ \begin{align} w_\textrm{usd} &= \begin{bmatrix} 100 \\ 50\\ -200\\ 51 \end{bmatrix},\\ &~\\ w^\prime &= \frac{w}{\sqrt{w^\textrm{T} w}} \quad \textrm{provides a unit length weight vector}, \\ &~\\ w^{\prime\prime} &= \frac{w}{\sum\limits_i |w_i|} \quad \textrm{provides another weight vector}. \end{align} $$ The "right" choice depends upon your intended usage of the weights.

For any set of portfolio weights (in consistent units of measure, e.g. USD), the variance calculation is straight forward. In your example, the USD volatility of your portfolio is:

$$ \begin{align} \hat{\sigma}_\textrm{usd}^2 &= w_\textrm{usd}^\textrm{T} \hat\Sigma w_\textrm{usd} \quad \textrm{estimated portfolio variance in USD}, \textrm{or}\\ &~\\ \hat{\sigma}_\textrm{usd} &= \sqrt{\hat{\sigma}_\textrm{usd}^2} \quad \textrm{estimated portfolio standard deviation in USD.}\end{align} $$

equally valid weights vector but would give a completely difference variance

No. Its not the same portfolio. The answer is likely different unless you enumerated two distinct portfolios with the same estimated risk as defined by your estimated variance matrix $\hat{\Sigma}$. Its not even a change of units, e.g. from one currency to another, or a normalization shown above. $$ \begin{bmatrix} 10 \\ 5\\ -20\\ 6 \end{bmatrix}\neq \alpha \begin{bmatrix} 100 \\ 50\\ -200\\ 51 \end{bmatrix} $$

  • 1
    $\begingroup$ Nice. When you have both long and short positions it is advantageous to calculate the variance (and standard deviation) of USD P&L, as you have done here. If you know the amount invested in the portfolio (the initial equity) you can compute the standard deviation of percent returns as a second step. (For long only unleveraged portfolios we often work with percent returns directly). $\endgroup$
    – nbbo2
    Jan 26, 2023 at 14:31
  • $\begingroup$ Harry: no broker will allow you to have a net portfolio value of -50 USD. They will close your account as soon as it is about to become negative. The portfolio you describe (in addition to A, B, C) must include some cash (at least 200 came from the intial short sale proceeds and possibly more was in the account beforehand) so its value will be non-negative. $\endgroup$
    – nbbo2
    Jan 27, 2023 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.