Home › Templates › Correlation matrix spreadsheet

Correlation Matrix Spreadsheet

A free stock correlation spreadsheet for Excel and Google Sheets. Paste the prices of up to 10 stocks or funds and it builds the returns, a colour-coded 10 × 10 correlation matrix, the covariance matrix, your portfolio's volatility from its weights, each holding's share of the risk, the diversification ratio and a rolling correlation chart for any pair.

Download Excel template (.xlsx) 665 KB · no macros · Excel 2016+ and Google Sheets · v1.0, 8 Nov 2026

Use it in Google Sheets: choose File → Import → Upload in Sheets and pick the .xlsx, or upload it to Google Drive and open it with Google Sheets. No sign-up, no email gate, no add-in, no paid data feed: you paste prices from any source.

Preview: the Example tab. The 10 assets, dates and prices are fictional (a seeded random walk) and say nothing about any real security.
0.18average correlation of the 45 pairs
0.59highest pair: Bond A / Bond B
−0.15lowest pair: Utility A / Bond A
10.9%portfolio volatility vs 18.0% weighted average
1.65diversification ratio
Tech ATech BBank AEnergy ARetail AUtility AREIT ABond ABond BGold A
Tech A1.000.520.430.300.380.290.320.050.020.08
Tech B0.521.000.420.300.350.290.320.02−0.020.05
Bank A0.430.421.000.360.360.310.480.030.040.07
Energy A0.300.300.361.000.310.300.32−0.040.01−0.02
Retail A0.380.350.360.311.000.300.35−0.06−0.040.01
Utility A0.290.290.310.300.301.000.32−0.15−0.100.02
REIT A0.320.320.480.320.350.321.00−0.02−0.020.04
Bond A0.050.020.03−0.04−0.06−0.15−0.021.000.590.07
Bond B0.02−0.020.040.01−0.04−0.10−0.020.591.000.00
Gold A0.080.050.07−0.020.010.020.040.070.001.00

Heatmap:+1 moved together0 no link−1 moved opposite

−0.6−0.4−0.20.00.20.40.6Apr 2024Jul 2024Oct 2024Jan 2025Apr 2025Jul 2025Oct 2025whole period 0.05Rolling 60-day correlation: Tech A vs Bond A (fictional)

What a correlation matrix tells you about a portfolio

A correlation coefficient measures how closely two return series moved together, from +1 (always in step) through 0 (no straight-line link) to −1 (always opposite). A correlation matrix puts every pair in one grid: tickers across the top and down the side, 1 on the diagonal, the same number above and below it.

That grid is the raw material of diversification. The SEC's investor education site defines diversification as "the practice of spreading money among different investments to reduce risk" and explains why it works:

"Historically, the returns of the three major asset categories have not moved up and down at the same time. Market conditions that cause one asset category to do well often cause another asset category to have average or poor returns."Investor.gov (SEC), Beginners' Guide to Asset Allocation, Diversification, and Rebalancing

FINRA makes the link to correlation explicit: diversification reduces the risk of major losses, and "this is especially true if your assets are 'uncorrelated,' meaning they react to economic events in ways independent of other assets in your portfolio" (FINRA, Asset Allocation and Diversification). The maths goes back to Harry Markowitz's 1952 paper "Portfolio Selection" (The Journal of Finance 7(1), 77–91), which measured a portfolio's risk by the variance of its return, built from the covariances between its holdings. This template does that calculation for you.

What's inside the spreadsheet

TabWhat you typeWhat it calculates
Start hereNothingSteps, formulas in plain words, how to read a correlation, colour key, limits, sources, disclaimer
SummaryNothingYour key numbers next to the Example's, and a guide to reading correlation values
PricesUp to 10 ticker names (B6:K6), dates in column A and closing prices from row 7 (up to 1,300 rows); return type, periods per year, rolling window, the pair to chart, portfolio weightsA check per price column; simple or log returns; 10 × 10 correlation matrix with heatmap; annualized covariance matrix; volatility per ticker; portfolio volatility; share of risk per holding; diversification ratio; average, highest and lowest pair; rolling correlation with a chart
ExampleAlready filled: 520 days of fictional prices for 10 made-up assets with weightsThe same tab with every result visible

Preview of the Example's input (first rows, 7 of the 10 columns):

DateTech ATech BBank AEnergy ARetail ABond AGold A
2024-01-02182.0096.5054.2071.8038.90101.2045.60
2024-01-03181.8197.0954.5771.5639.69101.4545.06
2024-01-04184.6796.7354.3871.6739.42101.6544.73
2024-01-05179.2496.2454.5772.0138.90100.9244.29
2024-01-08183.0996.8955.1372.8538.73101.0044.07
2024-01-09183.8798.0154.4474.3138.85100.8143.30

How to use it

  1. Download closing prices for the tickers you want to compare, ideally adjusted for splits and dividends, at the same frequency (daily, weekly or monthly). About 260 rows is a year of daily data.
  2. Open Prices. Type up to 10 ticker names in B6:K6. Paste the dates in column A from row 7, oldest first, and each ticker's prices under its name. Keep one row per shared date: if one market was closed, drop that date for all tickers.
  3. Set the return type (O5: Simple or Log), periods per year (O6: 252 daily, 52 weekly, 12 monthly) and the rolling window (O7). Pick two tickers for the rolling chart in O8 and O9.
  4. Check that the Status in O12 says OK. If not, it names the problem: fewer than 2 tickers, a gap in the dates, dates out of order, a missing price, a column with prices but no name, a duplicate name or a price that never changes. Row 5 shows the check for each column.
  5. Read the matrix (row 39), the covariance matrix (row 52) and the pair list (row 80). To see portfolio volatility, type weights in O66:O75 in any scale: 25 or 25% both work, and the sheet rescales them to 100%.

How to build a correlation matrix in Excel

Excel's CORREL "returns the correlation coefficient of two cell ranges" (Microsoft Support). Google Sheets' CORREL "calculates r, the Pearson product-moment correlation coefficient of a dataset" and "is synonymous with PEARSON" (Google Docs Editors Help). Both skip text, so the blank-looking cells the template leaves past your last row do not count. The steps:

1. Returns: AJ8 = B8/B7 − 1 (fill down and across)

2. One cell per pair: =CORREL(returns of ticker i, returns of ticker j)

3. Heatmap: Conditional formatting → Color scale, −1 blue, 0 white, +1 red

Many guides use the Analysis ToolPak (Data → Data Analysis → Correlation). It works, but it writes values once and fills only half the grid. Formulas update when you paste new prices. This template writes each of the 100 cells as its own CORREL with fixed ranges, so it needs no OFFSET, INDIRECT or array formulas and gives the same result in Excel, Google Sheets and LibreOffice.

Exact formulas from the Example tab (the IF wrappers keep cells blank until the inputs pass the checks):

FieldFormula
Simple or log return (AJ8)=IF(AND(B$5="OK",ISNUMBER(B8)),IF($O$5="Log",LN(B8/B7),B8/B7-1),"")
Correlation, Tech A vs Tech B (P39)=IF(AND($O$12="OK",$B$5="OK",$C$5="OK"),CORREL($AJ$8:$AJ$1306,$AK$8:$AK$1306),"")
Covariance, annualized (P52)=IF(AND($O$12="OK",$B$5="OK",$C$5="OK"),COVARIANCE.S($AJ$8:$AJ$1306,$AK$8:$AK$1306)*$O$6,"")
Volatility, annualized (Q66)=IF(AND($O$12="OK",$B$5="OK"),STDEV.S($AJ$8:$AJ$1306)*SQRT($O$6),"")
Weight used, rescaled to 100% (P66)=IF($O$23="OK",IF(N66="","",N(O66)/SUM($O$66:$O$75)),"")
Covariance with the portfolio (S66)=IF(ISNUMBER(P66),SUMPRODUCT($O$52:$X$52,$O$62:$X$62),"")
Share of portfolio risk (T66)=IF(ISNUMBER(P66),P66*S66/$O$24^2,"")
Portfolio volatility (O24)=IF($O$23="OK",SQRT(SUMPRODUCT($P$66:$P$75,$S$66:$S$75)),"")
Diversification ratio (O26)=IF($O$23="OK",$O$25/$O$24,"")
Average correlation of all pairs (O18)=IF($O$12="OK",AVERAGE($Q$80:$Q$124),"")
Highest pair (O20)=IF($O$12="OK",INDEX($O$80:$O$124,MATCH($O$19,$Q$80:$Q$124,0))&" / "&INDEX($P$80:$P$124,MATCH($O$19,$Q$80:$Q$124,0)),"")
Rolling correlation, row 67 (AW67)=IF(AND($O$29="OK",(ROW()-7)>=$O$7,(ROW()-7)<=$O$14),IFERROR(CORREL(INDEX($AU$8:$AU$1306,(ROW()-7)-$O$7+1):AU67,INDEX($AV$8:$AV$1306,(ROW()-7)-$O$7+1):AV67),""),"")

Portfolio volatility from the covariance matrix

Correlation shows direction and tightness; covariance adds size. Excel's COVARIANCE.S "returns the sample covariance, the average of the products of deviations for each data point pair in two data sets" (Microsoft Support; the same function exists in Google Sheets). For two assets, covariance = correlation × volatility A × volatility B. Portfolio variance adds up every pair, weighted:

σ²p = Σi Σj wi · wj · covij   →  σp = √σ²p

Textbook versions use MMULT(TRANSPOSE(w), MMULT(Σ, w)), which needs array entry in older Excel. The template splits it into two plain steps: for each holding, SUMPRODUCT of its covariance row with the weights row gives its covariance with the portfolio; then SUMPRODUCT of the weights with those values gives the variance. The same numbers give each holding's share of portfolio risk = weight × covariance with portfolio ÷ portfolio variance. The shares add up to 100%.

All covariances and volatilities are annualized by the periods-per-year setting (variance × 252 for daily data, volatility × √252), which assumes returns are not linked from one period to the next.

Diversification ratio

If every pair had a correlation of +1, portfolio volatility would equal the weighted average of the holdings' volatilities. Anything below +1 pulls it lower. The diversification ratio puts a number on that gap:

diversification ratio = Σ (wi × σi) / σp

A ratio of 1.00 means no benefit; higher means more of the stand-alone risk cancels out. The ratio is studied in the portfolio construction literature, for example by Choueifaty, Froidure and Reynier, whose paper presents "new mathematical properties of the Diversification Ratio" and builds on Choueifaty and Coignard's "Toward Maximum Diversification" (SSRN abstract). The sheet also shows the same idea as a percentage: volatility removed = 1 − portfolio volatility ÷ weighted average volatility.

Rolling correlation

One number for the whole period hides change. The rolling correlation recalculates CORREL over the last W returns on every row (W = 60 in the Example) for the pair you pick, and the chart plots it. The range is built as INDEX(column, k − W + 1):cell, which works in Excel, Google Sheets and LibreOffice without OFFSET.

In the Example, Tech A and Bond A have a whole-period correlation of 0.05, which looks like "no link". The rolling line tells a different story: it runs from −0.33 to 0.38. The fictional data were generated with the bond's response to the market switched from negative to positive halfway through, to show what a regime change looks like. Real correlations shift too, and a single full-period figure averages the two regimes away.

Worked example from the sample data

The Example tab holds 520 daily prices (519 returns) from 2024-01-02 to 2025-12-29 for 10 fictional assets, with simple returns and 252 periods per year.

Asset (fictional)WeightVolatilityShare of portfolio risk
Tech A15%28.1%31.1%
Tech B10%29.0%19.5%
Bank A10%21.2%13.5%
Energy A10%23.3%12.4%
Retail A10%21.2%12.0%
Utility A5%13.7%2.8%
REIT A5%21.8%5.5%
Bond A20%6.1%1.6%
Bond B10%5.8%0.6%
Gold A5%14.9%0.9%
Portfolio100%10.9%100%

Common mistakes

Limits

FAQ

How do you create a correlation matrix in Excel?

Turn prices into returns first (=B8/B7-1, filled down). Then put =CORREL(returns of A, returns of B) in each cell of a grid with the tickers across the top and down the side. The diagonal is 1 and the grid is symmetric. Excel's Analysis ToolPak (Data → Data Analysis → Correlation) builds the same grid once, as values that do not update; CORREL formulas update when you paste new prices. This template has the 10 × 10 grid ready.

Should I correlate prices or returns?

Returns. Two price lines that both trend up look highly correlated even when their day-to-day moves are unrelated. Portfolio risk comes from how returns move together, so the template converts every price series to periodic returns before it calls CORREL or COVARIANCE.S.

What correlation is good for diversification?

There is no official cut-off. The lower the correlation between two holdings, the more their combined volatility falls below the weighted average of their volatilities; at +1 there is no reduction at all. Correlations also change over time, which is why the sheet adds a rolling correlation chart.

How do you calculate portfolio volatility from a correlation matrix?

Portfolio variance = the sum over all pairs i, j of w_i × w_j × σ_i × σ_j × ρ_ij, where σ_i × σ_j × ρ_ij is the covariance. Volatility is the square root. The sheet does it with COVARIANCE.S and SUMPRODUCT instead of MMULT, so it works the same way in Excel and Google Sheets.

What window should I use for a rolling correlation?

Shorter windows react faster but are noisier; longer windows are steadier but lag. With daily data, 60 returns is about three months and 252 about a year. The window is a setting (O7), so you can compare both.

Does this correlation matrix spreadsheet work in Google Sheets?

Yes. In Google Sheets choose File → Import → Upload and pick the .xlsx, or upload it to Google Drive and open it with Google Sheets. It uses only CORREL, COVARIANCE.S, STDEV.S, SQRT, LN, SUMPRODUCT, SUM, AVERAGE, MAX, MIN, INDEX, MATCH, COUNT, COUNTIF, COUNTIFS, IF, AND, OR, NOT, ISNUMBER, IFERROR, N, ROW, TEXT, ABS. No macros, MMULT, OFFSET or dynamic arrays.

Related tools and templates

Educational template only, not investment advice. Example data is fictional: the assets, dates and prices are generated to show the formulas and say nothing about any real security or future result. Past correlations and volatility can change. Sources: Investor.gov (SEC), Beginners' Guide to Asset Allocation, Diversification, and Rebalancing and Asset Allocation and Diversification; FINRA, Asset Allocation and Diversification; H. Markowitz, "Portfolio Selection", The Journal of Finance 7(1), 77–91, 1952 (doi); Microsoft Support, CORREL and COVARIANCE.S; Google Docs Editors Help, CORREL and COVARIANCE.S; Choueifaty, Froidure and Reynier, "Properties of the Most Diversified Portfolio", Journal of Investment Strategies 2(2), 2013 (SSRN). Retrieved 8 November 2026.