Portfolio Risk: Understanding Variance and Correlation
When investing in stocks without prior knowledge of returns, there is an inherent degree of uncertainty, which implies that stock returns are random variables. This means that prices can fluctuate, resulting in uncertain outcomes. The extent to which actual returns deviate from their mean value is called variance. In statistics, variance is a measure of a stock's riskiness or volatility.
Certain stocks have low variances, meaning their returns tend to be close to the mean, while others have high variances and are widely spread around the mean. This concept may seem straightforward for individual assets but becomes more complex when considering portfolios. Portfolio variance cannot simply be calculated by summing the variances of the underlying stocks due to the correlation between assets. The correlation between assets affects their riskiness, implying that it should be included in portfolio variance calculations.
In addition to variances and correlations, individual risk levels of stocks also play a role in calculating portfolio variance. Furthermore, portfolio weights are essential components of this calculation as well. Correlation is an intuitive aspect of portfolio risk, suggesting that correlation coefficients influence the riskiness of investments. The presence or absence of correlation between assets affects their combined risk, which should be accounted for in portfolio variance calculations.
Standard deviation is often used to indicate risk, with its value being the square root of the variance. Both variance and standard deviation are utilized in practice for assessing investment risk. A portfolio's variance is calculated by taking the weights multiplied by the variances of individual stocks (σ1 and σ2 for stock 1 and 2). To account for correlation between stocks, the formula must include a term representing this correlation.
To rewrite the formula incorporating covariance instead of correlation times the variances, matrix notation can be employed. This simplifies the calculation, presenting it as weights transposed multiplied by the covariance matrix followed by the weights themselves. The resulting covariance matrix contains two variances on its diagonal and covariances between stocks on the off-diagonal terms.
Calculating Portfolio Variance with Python
Portfolio variance can be calculated using a straightforward formula but applying matrix notation simplifies the process significantly. It begins by taking daily returns from the price data, as variance is determined from returns rather than prices. Utilizing Python to calculate the covariance matrix is also feasible and efficient.
After determining the necessary elements, calculating portfolio variance involves multiplying weights with variances for individual stocks (σ1 and σ2). The formula must include a term representing correlation between stocks, making it slightly more complex. However, utilizing matrix notation simplifies this process by employing the dot product function from numpy for multiplication.
Weighting of Portfolio
For simplicity, an equal-weighted portfolio is considered in this example. This means that each stock contributes equally to the overall risk assessment of the portfolio. Applying the formula for calculating portfolio variance involves multiplying the weights with the covariance matrix and then with the normal weights again. It's essential to utilize the dot product function properly to ensure accurate calculations.
Standard Deviation Calculation
Once the portfolio variance is calculated, determining standard deviation requires only taking its square root. This provides a clear measure of the overall risk associated with the investment portfolio.
Implementing Portfolio Risk in Real-World Investing
Portfolio risk is an essential concept for investors and financial analysts alike. Understanding how to calculate and manage portfolio variance helps ensure that investment portfolios are aligned with their intended objectives. Furthermore, incorporating correlation coefficients into this process allows for more accurate assessments of potential risks and rewards associated with investments.
For practical applications, utilizing Python's matrix operations can simplify the calculation of portfolio risk. This enables users to efficiently assess and mitigate risks within their investment portfolios. By integrating these concepts effectively, investors can make informed decisions regarding asset allocation and overall portfolio management.
"WEBVTTKind: captionsLanguage: enlet's talk about portfolio risk when you invest in stocks you don't know beforehand what your return will be prices go up and down so there is a degree of uncertainty which implies that stock return is a random variable the extent to which the actual returns are spread around their mean value is called variance here is the official formula for variant it is a great indication of stocks riskiness or volatility you might have come across variants in your statistics class certain stocks have a small variance that means their returns are always close to the mean like the returns distribution here in red sometimes stocks have a high variance and are widely spread around the mean like the distribution here in blue this might be easy to understand for a single asset but how does this work for a portfolio well portfolio variance isn't simply the sum of all variances of the underlying stocks and due to the correlation between the assets it becomes more complicated since the assets in your portfolio correlate ie move together or in the opposite direction you intuitively understand that this will influence the riskiness of your investment that implies that correlation should be an ingredient in your portfolio variance also the individual risk levels of the stocks are part of the calculation as well as the portfolio weights lastly you might come across standard deviation used as an indication of risk this is simply the square root of the variance and both are used in practice suppose I calculate the variance of a portfolio with two stocks the portfolio variance is simply calculated by taking the weights times the variance is Sigma 1 and 2 for stock 1 and 2 respectively I need to add a term to account for correlation between the stocks and that's why I multiply W 1 W 2 Rho the correlation coefficient and the variance is Sigma 1 and 2 this last term is actually what we call the covariance so let's rewrite the formula and insert the covariance instead of the correlation times the variances let's take that last equation from the previous slide this one is long and difficult to work with hence we can write it shorter and smarter if we use some matrix notation it then becomes weights transposed times the covariance matrix times the weights the covariance matrix depicted here in the middle contains two variances on the diagonal and the covariances between acid one and two on the off diagonal terms this is something we can actually implement easily in Python let's start from the beginning by taking the price data again first remember to calculate the daily returns using the percentage change function as we need to calculate variance from our set of returns not from prices then we can let Python calculate our covariance matrix for us very easily so now we almost have all ingredients to calculate the portfolio variance we need to take a short additional step which is to analyze our volatility by multiplying it with 250 which is the amount of trading days in a year don't worry about it for now and you'll learn more about this in the next chapter last we need to weight of our portfolio we have five stocks here so let's create a simple equal weight of portfolio now apply the formula and multiply the transpose weights with the covariance matrix and then with the normal weights again make sure to use the dot multiplier here the numpy dot function takes only two arguments to multiply so start with the covariance matrix with normal weights and then multiply that whole thing with the weights transposed and that gives you the portfolio variance last let's take the square root of the variance to calculate the standard deviation like this let's breaklet's talk about portfolio risk when you invest in stocks you don't know beforehand what your return will be prices go up and down so there is a degree of uncertainty which implies that stock return is a random variable the extent to which the actual returns are spread around their mean value is called variance here is the official formula for variant it is a great indication of stocks riskiness or volatility you might have come across variants in your statistics class certain stocks have a small variance that means their returns are always close to the mean like the returns distribution here in red sometimes stocks have a high variance and are widely spread around the mean like the distribution here in blue this might be easy to understand for a single asset but how does this work for a portfolio well portfolio variance isn't simply the sum of all variances of the underlying stocks and due to the correlation between the assets it becomes more complicated since the assets in your portfolio correlate ie move together or in the opposite direction you intuitively understand that this will influence the riskiness of your investment that implies that correlation should be an ingredient in your portfolio variance also the individual risk levels of the stocks are part of the calculation as well as the portfolio weights lastly you might come across standard deviation used as an indication of risk this is simply the square root of the variance and both are used in practice suppose I calculate the variance of a portfolio with two stocks the portfolio variance is simply calculated by taking the weights times the variance is Sigma 1 and 2 for stock 1 and 2 respectively I need to add a term to account for correlation between the stocks and that's why I multiply W 1 W 2 Rho the correlation coefficient and the variance is Sigma 1 and 2 this last term is actually what we call the covariance so let's rewrite the formula and insert the covariance instead of the correlation times the variances let's take that last equation from the previous slide this one is long and difficult to work with hence we can write it shorter and smarter if we use some matrix notation it then becomes weights transposed times the covariance matrix times the weights the covariance matrix depicted here in the middle contains two variances on the diagonal and the covariances between acid one and two on the off diagonal terms this is something we can actually implement easily in Python let's start from the beginning by taking the price data again first remember to calculate the daily returns using the percentage change function as we need to calculate variance from our set of returns not from prices then we can let Python calculate our covariance matrix for us very easily so now we almost have all ingredients to calculate the portfolio variance we need to take a short additional step which is to analyze our volatility by multiplying it with 250 which is the amount of trading days in a year don't worry about it for now and you'll learn more about this in the next chapter last we need to weight of our portfolio we have five stocks here so let's create a simple equal weight of portfolio now apply the formula and multiply the transpose weights with the covariance matrix and then with the normal weights again make sure to use the dot multiplier here the numpy dot function takes only two arguments to multiply so start with the covariance matrix with normal weights and then multiply that whole thing with the weights transposed and that gives you the portfolio variance last let's take the square root of the variance to calculate the standard deviation like this let's break\n"