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.
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.
| Tech A | Tech B | Bank A | Energy A | Retail A | Utility A | REIT A | Bond A | Bond B | Gold A | |
|---|---|---|---|---|---|---|---|---|---|---|
| Tech A | 1.00 | 0.52 | 0.43 | 0.30 | 0.38 | 0.29 | 0.32 | 0.05 | 0.02 | 0.08 |
| Tech B | 0.52 | 1.00 | 0.42 | 0.30 | 0.35 | 0.29 | 0.32 | 0.02 | −0.02 | 0.05 |
| Bank A | 0.43 | 0.42 | 1.00 | 0.36 | 0.36 | 0.31 | 0.48 | 0.03 | 0.04 | 0.07 |
| Energy A | 0.30 | 0.30 | 0.36 | 1.00 | 0.31 | 0.30 | 0.32 | −0.04 | 0.01 | −0.02 |
| Retail A | 0.38 | 0.35 | 0.36 | 0.31 | 1.00 | 0.30 | 0.35 | −0.06 | −0.04 | 0.01 |
| Utility A | 0.29 | 0.29 | 0.31 | 0.30 | 0.30 | 1.00 | 0.32 | −0.15 | −0.10 | 0.02 |
| REIT A | 0.32 | 0.32 | 0.48 | 0.32 | 0.35 | 0.32 | 1.00 | −0.02 | −0.02 | 0.04 |
| Bond A | 0.05 | 0.02 | 0.03 | −0.04 | −0.06 | −0.15 | −0.02 | 1.00 | 0.59 | 0.07 |
| Bond B | 0.02 | −0.02 | 0.04 | 0.01 | −0.04 | −0.10 | −0.02 | 0.59 | 1.00 | 0.00 |
| Gold A | 0.08 | 0.05 | 0.07 | −0.02 | 0.01 | 0.02 | 0.04 | 0.07 | 0.00 | 1.00 |
Heatmap:+1 moved together0 no link−1 moved opposite
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
| Tab | What you type | What it calculates |
|---|---|---|
| Start here | Nothing | Steps, formulas in plain words, how to read a correlation, colour key, limits, sources, disclaimer |
| Summary | Nothing | Your key numbers next to the Example's, and a guide to reading correlation values |
| Prices | Up 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 weights | A 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 |
| Example | Already filled: 520 days of fictional prices for 10 made-up assets with weights | The same tab with every result visible |
Preview of the Example's input (first rows, 7 of the 10 columns):
| Date | Tech A | Tech B | Bank A | Energy A | Retail A | Bond A | Gold A |
|---|---|---|---|---|---|---|---|
| 2024-01-02 | 182.00 | 96.50 | 54.20 | 71.80 | 38.90 | 101.20 | 45.60 |
| 2024-01-03 | 181.81 | 97.09 | 54.57 | 71.56 | 39.69 | 101.45 | 45.06 |
| 2024-01-04 | 184.67 | 96.73 | 54.38 | 71.67 | 39.42 | 101.65 | 44.73 |
| 2024-01-05 | 179.24 | 96.24 | 54.57 | 72.01 | 38.90 | 100.92 | 44.29 |
| 2024-01-08 | 183.09 | 96.89 | 55.13 | 72.85 | 38.73 | 101.00 | 44.07 |
| 2024-01-09 | 183.87 | 98.01 | 54.44 | 74.31 | 38.85 | 100.81 | 43.30 |
How to use it
- 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.
- 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.
- 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.
- 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.
- 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):
| Field | Formula |
|---|---|
| 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.
- Correlation: the 45 pairs average 0.18. The highest is Bond A / Bond B at 0.59; the lowest is Utility A / Bond A at −0.15. The seven stock-like assets correlate with each other at 0.29 to 0.52.
- Volatility: annualized volatilities run from 5.8% (Bond B) to 29.0% (Tech B). With the Example weights, the weighted average is 18.00%.
- Portfolio volatility: 10.94%, so diversification removes 39.2% of the weighted-average risk. Diversification ratio = 18.00% / 10.94% = 1.65.
- Who carries the risk: Tech A is 15% of the money but 31.1% of the portfolio's variance; Bond A is 20% of the money and 1.6% of the variance.
| Asset (fictional) | Weight | Volatility | Share of portfolio risk |
|---|---|---|---|
| Tech A | 15% | 28.1% | 31.1% |
| Tech B | 10% | 29.0% | 19.5% |
| Bank A | 10% | 21.2% | 13.5% |
| Energy A | 10% | 23.3% | 12.4% |
| Retail A | 10% | 21.2% | 12.0% |
| Utility A | 5% | 13.7% | 2.8% |
| REIT A | 5% | 21.8% | 5.5% |
| Bond A | 20% | 6.1% | 1.6% |
| Bond B | 10% | 5.8% | 0.6% |
| Gold A | 5% | 14.9% | 0.9% |
| Portfolio | 100% | 10.9% | 100% |
Common mistakes
- Correlating prices instead of returns. Trending price lines look correlated even when their moves are not.
- Misaligned dates. If one column is shifted by a day, every correlation with it drops. Use one row per shared date.
- Mixing frequencies. Daily, weekly and monthly returns give different correlations. Assets that close in different time zones look less correlated on daily data than on weekly data.
- Too short a sample. With 30 returns a correlation of 0.3 can easily be noise. The sheet flags samples under 60 and under 250 returns.
- Treating the matrix as fixed. Correlations change, and they can rise together in sell-offs, just when diversification is wanted. Check the rolling chart.
- Population vs sample formulas.
COVARIANCE.PandSTDEV.Pare the population versions (divide by n);COVARIANCE.SandSTDEV.Sare the sample versions (divide by n − 1). Mixing them makes volatility and covariance slightly inconsistent. This sheet uses the sample versions throughout. Correlation is the same either way. - Reading correlation as cause. Two assets can move together because both respond to the same driver.
Limits
- Everything is estimated from past returns. It describes the sample you paste, not the future.
- Volatility is one view of risk. It does not show the worst day or the deepest drawdown.
- Annualizing by √(periods per year) assumes returns are independent from one period to the next.
- Up to 10 tickers and 1,300 rows per tab; every named ticker needs a price on every date row.
- Weights must be 0 or more (no short positions) and are rescaled to 100%.
- Recalculation was tested in LibreOffice against an independent numpy model. The file uses only functions that exist in Excel 2016+ and Google Sheets.
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
- Sharpe ratio calculatorReturn per unit of volatility
- Portfolio rebalancing spreadsheetGet back to your target weights
- Stock portfolio trackerHoldings, cost basis and gains
- Investment trackerAll accounts in one place
- CAGR calculatorAnnualized growth rate
- All templatesFree spreadsheets
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.