# Solving for volatility of a portfolio via its components

I have only been able to find the calculation for computing volatility for two assets, and I don't believe one can solve for covariance of $n$ assets where $n>2$ . Is there a method for solving for a portfolio's volatility through it's components purely mathematically? I can always solve via simulation but mathematically would be more precise.

• Let $X_1,\dotsc,X_n$ be random variables. Then $$\text{Var}\left(\sum_{i=1}^n X_i\right)=\sum_{i=1}^n \text{Var}(X_i)+\sum_{i=1}^n \sum_{j=1}^n \text{Cov}(X_i,X_j)$$. This works for $n=2,3,\dotsc$, so not only for $n=2$. Is that what you are asking? – Richard Hardy Sep 2 '16 at 19:17
• Also the elements of the covariance matrix are $\rho_{ij} \sigma_i \sigma_j$ so you can compute them if (if you don't have them) from the correlation matrix and the volatilities. Then you can use Richard Hardy's formula. – noob2 Sep 2 '16 at 19:50
• yes it is @richard hardy – FX_NINJA Sep 3 '16 at 0:46
• It's also really easy with matrix math. $w'\Sigma w$ – John Sep 19 '16 at 15:29

Take variance as a measure of volatility. Let $X_1,\dotsc,X_n$ be a set of random variables (e.g. asset returns). Let $a_1,\dotsc,a_n$ be a corresponding set of weights (e.g. portfolio weights). Then the variance of the linear combination of the random variables (the volatility of the portfolio) is
\begin{aligned} \text{Var}\left(\sum_{i=1}^n a_i X_i\right) &= \sum_{i=1}^n \text{Var}(a_i X_i)+\sum_{i=1}^n \sum_{j=1}^n \text{Cov}(a_i X_i,a_j X_j) \\ &= \sum_{i=1}^n a_i^2 \text{Var}(X_i)+\sum_{i=1}^n \sum_{j=1}^n a_i a_j \text{Cov}(X_i,X_j). \\ \end{aligned}
This works for $n=2,3,\dotsc$, so not only for $n=2$. (Also, it is a very general result. It does not require any distributional assumptions.)