Calculating Covariance for Stocks (2024)

Daily Return for Two Stocks Using the Closing Prices
DayABC ReturnsXYZ Returns
11.1%3.0%
21.7%4.2%
32.1%4.9%
41.4%4.1%
50.2%2.5%

Next, calculate the average return for each stock:

  • For ABC, it would be (1.1 + 1.7 + 2.1 + 1.4 + 0.2) / 5 = 1.30.
  • For XYZ, it would be (3 + 4.2 + 4.9 + 4.1 + 2.5) / 5 = 3.74.

Then, take the difference between ABC's return and ABC's average returnand multiply it by the difference between XYZ's return and XYZ's average return.

Finally, divide the result by the sample size and subtract one. If it was the entire population, you could divide by the population size.

This is represented by the following equation:

Covariance=(ReturnABCAverageABC)(ReturnXYZAverageXYZ)(SampleSize)1\text{Covariance}=\frac{\sum{\left(Return_{ABC}\text{ }-\text{ }Average_{ABC}\right)\text{ }*\text{ }\left(Return_{XYZ}\text{ }-\text{ }Average_{XYZ}\right)}}{\left(\text{Sample Size}\right)\text{ }-\text{ }1}Covariance=(SampleSize)1(ReturnABCAverageABC)(ReturnXYZAverageXYZ)

Using our example of ABC and XYZ above, the covariance is calculated as:

  • = [(1.1 - 1.30) x (3 - 3.74)] + [(1.7 - 1.30) x (4.2 - 3.74)] + [(2.1 - 1.30) x (4.9 - 3.74)] + …
  • = [0.148] + [0.184] + [0.928] + [0.036] + [1.364]
  • = 2.66 / (5 - 1)
  • = 0.665

In this situation, we are using a sample, so we divide by the sample size (five) minus one.

The covariance between the two stock returns is 0.665. Because this number is positive, the stocks move in the same direction. In other words, when ABC had a high return, XYZ also had a high return.

If the result were negative, then the two stocks would tend to have opposite returns: when one had a positive return, the other would have a negative return.

Finding Covariance With Microsoft Excel

In MS Excel, you use one of the following functions to find the covariance:

  • = COVARIANCE.S() for a sample
  • = COVARIANCE.P() for a population

You will need to set up the two lists of returns in vertical columns as in Table 1. Then, when prompted, select each column. In Excel, each list is called an "array," and two arrays should be inside the brackets, separated by a comma.

Uses of Covariance

Covariance can tell how the stocks move together, but to determine the strength of the relationship, look at theircorrelation. The correlation should, therefore, be used in conjunction with the covariance, and is represented by this equation:

Correlation=ρ=cov(X,Y)σXσYwhere:cov(X,Y)=CovariancebetweenXandYσX=StandarddeviationofXσY=StandarddeviationofY\begin{aligned} &\text{Correlation}=\rho=\frac{cov\left(X, Y\right)}{\sigma_X\sigma_Y}\\ &\textbf{where:}\\ &cov\left(X, Y\right)=\text{Covariance between X and Y}\\ &\sigma_X=\text{Standard deviation of X}\\ &\sigma_Y=\text{Standard deviation of Y}\\ \end{aligned}Correlation=ρ=σXσYcov(X,Y)where:cov(X,Y)=CovariancebetweenXandYσX=StandarddeviationofXσY=StandarddeviationofY

The equation above reveals that the correlation between two variables is the covariance between both variables divided by the product of the standard deviation ofthe variables. While both measures reveal whether two variables are positively or inversely related, the correlation provides additional information by determining the degree to which both variables move together.

The correlation will always have a measurement value between -1 and 1, and it adds a strength value on how the stocks move together.

If the correlation is 1, they move perfectly together, and if the correlation is -1, the stocks move perfectly in opposite directions. If the correlation is 0, then the two stocks move in random directions from each other.

In short, covariance tells you whether two variables change the same way while correlation reveals how a change in one variable affects a change in the other.

You also may use covariance to find the standard deviation of a multi-stock portfolio. The standard deviation is the accepted calculation for risk, which is extremely important when selecting stocks. Most investors would want to select stocks that move in opposite directions because the risk will be lower, though they'll provide the same amount of potential return.

How Does Covariance Differ From Variance?

Variance measures the dispersion of values or returns of an individual variable or data point about the mean. It looks at a single variable. Covariance instead looks at how the dispersion of the values of two variables corresponds with respect to one another.

Where Is Covariance Used in Finance?

If two stocks have share prices with a positive covariance, they are both likely to move in the same direction when responding to market conditions.If they have negative covariance they tend to move in opposite directions. Covariance is used in modern portfolio theory (MPT), when constructing efficient investment portfolios. In order to achieve the optimal risk-return trade-off one should identify assets that have a low or negative correlation.

How Do Covariance and Correlation Differ?

The correlation coefficient of a pair of variables is derived by taking the covariance and dividing it by the product of each variable's standard deviation:

Correlation (ρ) = cov(X,Y)/(σX σY)

​Correlation is therefore a normalized or rangebound interpretation of how two variables move together.

The Bottom Line

Covariance is a common statistical calculation that can show how two stocks tend to move together. Investors can use it to lower their portfolio risk by selecting stocks that move in opposite directions.

However, because covariance is calculated using historical returns, it can never provide complete certainty about the future. It should not be used on its own to construct a portfolio. Instead, it shouldbe used in conjunction with other calculations such as correlation or standard deviation.

Calculating Covariance for Stocks (2024)

FAQs

How do you calculate covariance in stocks? ›

In other words, you can calculate the covariance between two stocks by taking the sum product of the difference between the daily returns of the stock and its average return across both the stocks.

How can I calculate covariance? ›

To calculate covariance, you can use the formula:Cov(X, Y) = Σ(Xi-µ)(Yj-v) / nWhere the parts of the equation are: Cov(X, Y) represents the covariance of variables X and Y. Σ represents the sum of other parts of the formula. (Xi) represents all values of the X-variable.

What is the covariance between stocks A and B? ›

It is denoted by ρ(A, B). Step 4: Finally, the covariance calculation between stock A and stock B can be derived by multiplying the standard deviation of returns of stock A, the standard deviation of returns of stock B, and the correlation between returns of stock A and stock B, as shown below.

What is the general formula for covariance? ›

The covariance between X and Y is defined as Cov(X,Y)=E[(X−EX)(Y−EY)]=E[XY]−(EX)(EY). Note that E[(X−EX)(Y−EY)]=E[XY−X(EY)−(EX)Y+(EX)(EY)]=E[XY]−(EX)(EY)−(EX)(EY)+(EX)(EY)=E[XY]−(EX)(EY).

How do you calculate correlation between stocks? ›

To find the correlation between two stocks, you'll start by finding the average price for each one. Choose a time period, then add up each stock's daily price for that time period and divide by the number of days in the period. That's the average price. Next, you'll calculate a daily deviation for each stock.

How do you find the covariance of a stock in Excel? ›

The covariance of the values in columns B and C of the spreadsheet can be calculated using the COVAR function using the formula =COVAR(B2:B13, C2:C13). It gives the result -0.000563, which indicates a negative correlation between the two sets of stocks.

How many covariance terms does a portfolio of 7 stocks have? ›

A portfolio of 7 stocks has **21** covariance terms. The covariance between two stocks is a measure of how much their returns tend to move together. The covariance of a stock with itself is always 0. So, for a portfolio of 7 stocks, there are 7C2 = 21 possible covariance terms, 7 of which are equal to 0.

How do you calculate covariance and correlation? ›

The covariance of x and y is 15.4. The correlation coefficient can be calculated as follows: r = C o v ( x , y ) / ( σ x ∗ σ y )

What is the covariance variance method? ›

The variance-covariance method for the value at risk calculates the standard deviation of price movements of an investment or security. Assuming stock price returns and volatility follow a normal distribution, the maximum loss within the specified confidence level is calculated.

What is covariance in stock market? ›

Covariance is a statistical method used to assess the relationship between two asset pricing movements. These are seen as having a positive covariance when two stocks tend to move together.

How do you find the covariance of two stocks with probability? ›

  1. To calculate the covariance of two stocks, you will need the historical returns for both stocks and the formula for covariance, which is:
  2. Covariance = [(Σ(xi - x̄) * (yi - ȳ)) / (n - 1)]
  3. Where:
  4. - Σ is the sum of.
  5. - xi is the return of stock X for each period.
  6. - x̄ is the average return of stock X.
Aug 15, 2021

What is the covariance of two stock portfolios? ›

Covariance is a statistical tool investors use to measure the relationship between the movement of two asset prices. A positive covariance means asset prices are moving in the same general direction. A negative covariance means asset prices are moving in opposite directions.

How do you calculate covariance step by step? ›

How to calculate sample covariance
  1. Gather the data from both samples. ...
  2. Calculate the mean for both the X and Y samples. ...
  3. Find the difference between each mean value. ...
  4. Multiply the difference for X and the difference for Y and perform the summation. ...
  5. Subtract one from the number of data points.
Jun 24, 2022

What is a good covariance value? ›

The size of covariance values depends on the difference between values in variables. For instance, if the values are between 1000 and 2000 in the variable, it possible to have high covariance. However, if the values are between 1 and 2 in both variables, it is possible to have a low covariance.

What is the difference between variance and covariance? ›

Covariance: An Overview. Variance and covariance are mathematical terms frequently used in statistics and probability theory. Variance refers to the spread of a data set around its mean value, while a covariance refers to the measure of the directional relationship between two random variables.

How do you find the covariance of two investments? ›

Example of Covariance
  1. Obtain the data. ...
  2. Calculate the mean (average) prices for each asset.
  3. For each security, find the difference between each value and mean price.
  4. Multiply the results obtained in the previous step.
  5. Using the number calculated in step 4, find the covariance.

What does it mean if the returns of two stocks A and B are negatively correlated? ›

What does it mean if the returns of two stocks, A and B, are negatively correlated? It means that, on average, if the returns of stock A are positive, the returns of stock B will be negative.

What is the formula for covariance using beta? ›

Beta (β) = {r (i, m) * SDi}/ SDm, Where r (i, m) is the correlation between the stock return 'i' and the market return m, SDi is the standard deviation of the stock return and SDm is the standard deviation of the market return. Note, standard deviation is the square root of variance.

What is the covariance between risk free asset and stock? ›

The rate of return of risk free asset is constant and doesn't move in any direction. Covariance measures the relationship between the two stocks and the direction in which they move as opposed to one another. Since risk free asset has a constant rate, there is no movement in it's rate of return.

Top Articles
Latest Posts
Article information

Author: Prof. Nancy Dach

Last Updated:

Views: 5734

Rating: 4.7 / 5 (57 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Prof. Nancy Dach

Birthday: 1993-08-23

Address: 569 Waelchi Ports, South Blainebury, LA 11589

Phone: +9958996486049

Job: Sales Manager

Hobby: Web surfing, Scuba diving, Mountaineering, Writing, Sailing, Dance, Blacksmithing

Introduction: My name is Prof. Nancy Dach, I am a lively, joyous, courageous, lovely, tender, charming, open person who loves writing and wants to share my knowledge and understanding with you.