New! Eligible SoFi members can invest in upcoming IPOs before they’re traded on the public market—only in the SoFi app.* Learn more

Measuring Covariance in Investments

February 08, 2021 · 4 minute read

We’re here to help! First and foremost, SoFi Learn strives to be a beneficial resource to you as you navigate your financial journey. Read more We develop content that covers a variety of financial topics. Sometimes, that content may include information about products, features, or services that SoFi does not provide. We aim to break down complicated concepts, loop you in on the latest trends, and keep you up-to-date on the stuff you can use to help get your money right. Read less

Measuring Covariance in Investments

Any investment portfolio can have a variety of assets — stocks, bonds, commodities. A portfolio could also have different types of the same asset: value vs growth stocks, high yield vs blue chip corporate bonds. Sometimes these assets move together, while other times they move in opposite directions.

One way to measure how assets relate to each other is covariance. This concept, which comes from statistics, is one of the key tenets behind why portfolio diversification matters: risk can be reduced by investing in a variety of assets.

By holding multiple assets, investors can reduce the idiosyncratic risk that one may cause (say, because of accounting fraud or malfeasance by executives) without bringing down their whole portfolio or missing out on gains by a particular sector. Diversification both works within sectors (for instance, owning a variety of tech stocks) or when it comes to asset allocation (like owning stocks and bonds).

But it’s not always obvious to investors who are doing portfolio management which assets will create more diversification. It involves not just making qualitative judgments about different assets but understanding their statistical relationship to each other. To get a handle on how diversification works, investors need to understand covariance.

What is Covariance?

Covariance measures the relationship between two changing quantities. If you take two quantities or variables, such as prices of two assets over a period of time, the covariance is the degree to which they move away from their respective averages.

Covariance is a measure of how variables move together or don’t move together, not a measure of the direction they move.

For stocks and other assets this matters because, when constructing a portfolio, investors want to know how their assets relate to each other. By reducing covariance, they can make a portfolio more diverse. It’s a way of handling investing risks.

Another way investors can gauge risk in their holdings is learning how to find portfolio beta, or its sensitivity to price swings in the broader market.

Can Covariance Be Negative?

When the variables move together, the covariance is positive (ie, both move above or both move below their respective averages); when they move in opposite directions, the covariance is negative.

Covariance can still be positive when the two variables move below their respective means. Remember, covariance measures how the variables are associated with each other.

Difference Between Covariance and Correlation

Now this might sound a lot like correlation. The two concepts are related but they are not identical.
For one, they use different units: correlation goes from 1 to -1. Correlation measures how strongly related the association between two variables are, either negatively or positively.

Why the Covariance Formula Matters

For an investor, the covariance formula is used when you want to determine the relationship between two assets. While the calculation itself can be easily done in Excel, it’s useful to walk through an example in order to understand how it works.

In the case of the formula below, we are using the equation for determining covariance from a sample of the total populations of the two variables, not the whole population. In the case of financial assets, this is likely the most relevant formula.

We will look at the returns of two stocks, in order to see how they’re related to each other. In this case, we already know the returns of one stock in the portfolio. When considering whether to buy a new one, we might want to consider the relationship between the new stock’s returns over time and the ones of a given stock in our portfolio.

This very quickly adds up to a large series of calculations, considering that a single portfolio can have dozens, hundreds, or in the case of large institutional or retail investors, thousands of assets. Any single calculation won’t tell an investor how a new asset would diversify their portfolio or not, but knowing the formula and using it on sample data can help show why it’s important.

How to Calculate Covariance

Covariance has a formula:
Cov (X,Y) = [SUM(x-xa) (y-ya)] / (n-1)
In the formula:

x is the values of the x variable. y is the values of the y variable.

xa is the average of the x variable, while ya is the average of y variable.

n is the number of data points.

Example of Using the Covariance Formula

For this example we will use two stocks, AAA Corp and BBB Corp. Below are AAA Corp’s returns over five years. It’s a hot growth stock whose returns grow over time as new products are rolled out and investors take notice.

2015: -15%
2016: -7%
2017: 25%
2018: 40%
2019: 50%
Average returns = 18.6%

Here are BBB Corps returns. They are more modest and steady and do not respond as quickly or intensely to market sentiment and swings.

2015: 5%
2016: 9%
2017: 11%
2018: 8%
2019: 12%
Average returns = 9%

Example of Finding the Covariance

For each stock, we subtract the average return from the return of a given year and then multiply the two results together, and add them up for every year.

[(-15-18.6)x(5-9)] + [(-7-18.6) x (9-9)] + [(25-18.6) x (11-9)] + [(40-18.6) x (8-9)] + [(50-18.6) x (12-9)] / (5-1)

After doing all the math (or running it through Excel), the covariance of these two stocks is 55. That it’s positive means the stocks tend to move in the same direction at the same time. When you look at the two figures, there are years where AAA has a negative return, and then a high positive return, whereas BBB has steady positive returns in the five-year sample.

But covariance isn’t just a measure of returns, but how returns vary relative to their mean. In the two years BBB had above average returns, AAA had very high and above average returns. For there to be negative covariance, the below and above average years would have to be not paired at all.

While these examples are not necessarily reflective of a real-world comparison between two assets in a portfolio, it shows how covariance can work and how to think about it when making investments.

Building a Portfolio With SoFi

SoFi Invest offers a variety of tools to build a concentrated or diversified portfolio, customized to where an investor is in their life, their risk tolerance, and what they need out of an investment account. With as little as $1, users can start investing.

Investors can trade commission-free and get access to other members of the SoFi community with exclusive events and programming.

Check out SoFi Invest today.

SoFi Invest®
The information provided is not meant to provide investment or financial advice. Investment decisions should be based on an individual’s specific financial needs, goals and risk profile. SoFi can’t guarantee future financial performance. Advisory services offered through SoFi Wealth, LLC. SoFi Securities, LLC, member FINRA / SIPC . SoFi Invest refers to the three investment and trading platforms operated by Social Finance, Inc. and its affiliates (described below). Individual customer accounts may be subject to the terms applicable to one or more of the platforms below.
1) Automated Investing—The Automated Investing platform is owned by SoFi Wealth LLC, an SEC Registered Investment Advisor (“Sofi Wealth“). Brokerage services are provided to SoFi Wealth LLC by SoFi Securities LLC, an affiliated SEC registered broker dealer and member FINRA/SIPC, (“Sofi Securities).
2) Active Investing—The Active Investing platform is owned by SoFi Securities LLC. Clearing and custody of all securities are provided by APEX Clearing Corporation.
3) Cryptocurrency is offered by SoFi Digital Assets, LLC, a FinCEN registered Money Service Business.
For additional disclosures related to the SoFi Invest platforms described above, including state licensure of Sofi Digital Assets, LLC, please visit Neither the Investment Advisor Representatives of SoFi Wealth, nor the Registered Representatives of SoFi Securities are compensated for the sale of any product or service sold through any SoFi Invest platform. Information related to lending products contained herein should not be construed as an offer or pre-qualification for any loan product offered by SoFi Lending Corp and/or its affiliates.
Investment Risk: Diversification can help reduce some investment risk. It cannot guarantee profit, or fully protect in a down market.
Disclaimer: The projections or other information regarding the likelihood of various investment outcomes are hypothetical in nature, do not reflect actual investment results, and are not guarantees of future results.

All your finances.
All in one app.

SoFi QR code, Download now, scan this with your phone’s camera

All your finances.
All in one app.

App Store rating

SoFi iOS App, Download on the App Store
SoFi Android App, Get it on Google Play

TLS 1.2 Encrypted
Equal Housing Lender