Register
Free toolNo sign-up

Analyze Inter-Stock Correlations for Hedging

A stock correlation matrix shows how closely the returns of several stocks move together. Each cell holds a correlation between −1 and +1 for a pair of stocks. Traders and investors use it to check diversification, find hedges, spot hidden concentration and shortlist candidates for pairs trading.

Correlation matrix of daily returns
0.81Most correlated

Bank A and Bank B

Least correlated0.08IT company and FMCG company
Average correlation0.296 pairs
Returns used59Daily log returns
Correlation of daily returns
Bank ABank BIT companyFMCG company
Bank A1.000.810.160.17
Bank B0.811.000.180.33
IT company0.160.181.000.08
FMCG company0.170.330.081.00

Correlations change over time. Check them over more than one period before relying on them.

Correlated pairs are the starting point for a cointegration test.Cointegration tester

The tool above builds the matrix from your own data. Paste a row of names and then one row of closing prices a day, for two to eight stocks or indices and at least ten days. It turns the prices into daily returns, works out the correlation of every pair, and shows the matrix as a heat map with the most correlated pair, the least correlated pair and the average. Your data stays in your browser. This guide explains how correlation is calculated, how to read the matrix, worked examples, how correlation affects a portfolio's risk, and the pitfalls to avoid.

What the correlation matrix tool does

PartWhat it does
InputA row of names, then one row of closing prices a day, 2 to 8 columns, at least 10 rows
ReturnsDaily log returns: the natural log of each day's close divided by the day before
MeasurePearson correlation of every pair of return series
OutputA heat map of the matrix, blue for positive and red for negative
SummaryThe most and least correlated pairs, the average correlation and the number of returns used
SampleSimulated prices for two banks, an IT company and an FMCG company; replace them with yours
PrivacyRuns in your browser; nothing is sent or stored

A short history of correlation in finance

Correlation began as a tool for studying heredity. In 1888 Francis Galton described "co-relation" between the measurements of parents and children, and in 1896 Karl Pearson gave the formula still used today, the product-moment correlation coefficient.1 For half a century it belonged to biology and statistics.

Finance took it up in 1952, when Harry Markowitz published "Portfolio Selection". His point was that the risk of a portfolio depends not only on the risk of each holding but on how the holdings move together. Two risky stocks whose returns are not perfectly correlated make a portfolio less risky than either alone.2 That idea, diversification measured by correlation, earned Markowitz a share of the 1990 Nobel prize in economics and became the base of modern portfolio management. William Sharpe's capital asset pricing model of 1964 built on it,4 measuring each stock's link to the market through market sensitivity, which is correlation scaled by relative volatility.

Later research found the weakness traders still meet: correlations are not stable. In 2001, François Longin and Bruno Solnik showed that correlations between equity markets rise in falling markets, just when diversification is wanted most.3 Indian traders saw the same thing in March 2020 and in March 2026, when stocks across sectors fell together. A correlation matrix is still the first check of a portfolio's concentration; it is not a promise of how the portfolio will behave in a crisis.

How correlation is calculated

The most common measure is the Pearson correlation of returns:

Formula
Correlation = covariance of the two return series ÷ (standard deviation of A × standard deviation of B)

Three rules matter:

  1. Use returns, not prices. Two prices that both rise over time can look highly correlated even if their daily moves are unrelated.
  2. Use the same dates for both stocks.
  3. Choose a window, such as the last 60 or 250 trading days.

The tool uses log returns, the natural log of today's close divided by yesterday's. For daily moves of a few per cent, log returns and simple percentage returns give almost the same correlation; log returns add up neatly over several days, which is why they are the usual choice.

A worked example by hand

Six days of returns, in per cent, for two stocks:

DayStock AStock BA minus its averageB minus its averageProduct
11.20.91.1000.7670.8433
2−0.8−0.4−0.900−0.5330.4800
30.50.70.4000.5670.2267
4−1.5−1.1−1.600−1.2331.9733
50.90.20.8000.0670.0533
60.30.50.2000.3670.0733

The averages are 0.10% for A and 0.133% for B. The products add up to 3.65; divided by five (the number of days less one), the covariance is 0.73. The standard deviations are 1.041 for A and 0.755 for B. The correlation is 0.73 ÷ (1.041 × 0.755) = 0.93. On every one of the six days, both stocks moved the same way, and their big days were big together. Six days are far too few to rely on; the tool asks for at least ten, and a useful window is sixty or more.

How to use the tool

  1. Download daily closing prices for the stocks you want to compare, for the same dates. Your broker's charts or an exchange's historical data both work.
  2. Put the names in the first row, separated by commas.
  3. Paste one row a day below, oldest first, with the prices in the same order as the names.
  4. The tool checks that every row has a price for every name and drops rows that do not.
  5. Read the heat map, then the summary: the most and least correlated pairs and the average.
  6. Change the window by pasting more or fewer rows, and see how much the figures move.

Reading the values

CorrelationMeaning
+0.8 to +1.0Very strong: the stocks usually move together
+0.5 to +0.8Strong
+0.2 to +0.5Moderate
−0.2 to +0.2Little or no relationship
Below −0.2The stocks tend to move in opposite directions

Negative correlations between individual Indian stocks are uncommon, because most stocks share exposure to the overall market. A correlation measures direction and consistency, not size: two stocks can be perfectly correlated while one moves twice as much as the other.

A worked example: four stocks

This is a hypothetical matrix of daily return correlations over one year:

Bank ABank BIT companyFMCG company
Bank A1.000.820.310.24
Bank B0.821.000.280.22
IT company0.310.281.000.18
FMCG company0.240.220.181.00

The two banks move closely together. Holding both adds little diversification. The FMCG company has the lowest correlation with the others, so it diversifies the most. A trader with equal positions in both banks has, for most purposes, one large bank position. The IT company and the FMCG company, at 0.18 with each other, are the pair that would most reduce a portfolio's swings if held together, though even they share some of the market's moves.

What a correlation figure really says

A correlation of 0.5 sounds like "half related", but its square is the better guide. The square of the correlation, called R squared, is the share of one stock's daily movement that the other explains. At 0.5, that share is 0.25: a quarter of the movement is shared and three quarters is the stock's own. At 0.8, the shared part is 0.64, nearly two thirds. At 0.3, it is under a tenth. So a correlation has to be high before two stocks are close substitutes, and a moderate correlation still leaves most of each stock's risk independent.

Other measures of correlation

The tool uses the Pearson correlation, the standard measure. Two others are worth knowing. Spearman's rank correlation compares the order of the days rather than their size, so one extreme day cannot dominate it; it suits short windows with an outlier, such as a result day. Correlation of weekly returns, instead of daily ones, smooths out the noise of single days and can show a relationship that daily data hides, at the cost of fewer data points. If the three measures disagree, the relationship is weaker than any one of them suggests.

Reading a heat map quickly

The tool colours each cell: deeper blue for a stronger positive correlation, red for a negative one, pale for close to zero. The diagonal is always 1, because every series moves perfectly with itself, and the matrix is the same above and below the diagonal. Read it in three passes:

  1. Look for blocks of deep blue. A block of three or four names that are all strongly correlated is one exposure, whatever their names.
  2. Look for the palest row. The stock or index whose row is palest is the one that adds the most diversification to the group.
  3. Look for red. A negative correlation is rare between Indian stocks; when it appears, check the data before you trust it. A split, a missing day or prices in the wrong column often cause it.

How correlation changes a portfolio's risk

Correlation decides how much of each holding's risk survives in the portfolio. For two stocks held in equal amounts, each with a yearly volatility of 25%, the portfolio's volatility is:

Correlation between the twoPortfolio volatility
1.025.0%
0.823.7%
0.521.7%
0.219.4%
0.017.7%
Formula
Portfolio variance = wA²σA² + wB²σB² + 2 wA wB ρ σA σB, where w is each weight, σ each volatility and ρ the correlation

At a correlation of 0.8, adding the second stock barely lowers risk. At 0.2, it takes about a fifth off. That is the whole case for diversification, and it is why the correlation of a new position matters as much as its own risk.

Correlation and the risk budget of two trades

Traders who risk a fixed amount per trade often forget that two open trades share their risk. Suppose two positions each have a typical daily swing of ₹5,000. Their combined swing depends on the correlation:

CorrelationCombined typical daily swing
1.0₹10,000
0.8₹9,487
0.5₹8,660
0.3₹8,062
0.0₹7,071

At a correlation of 0.8, two positions carry almost twice the risk of one. At zero, they carry about 1.4 times. A trader who sets a daily risk limit for the whole account can use the matrix to decide how many correlated positions fit inside it, instead of adding them one at a time and finding out on a bad day.

Correlation and market sensitivity

Market sensitivity measures how much a stock moves with the market, Nifty for example. It is correlation scaled by the ratio of volatilities:

Formula
Market sensitivity = correlation with the market × (stock's volatility ÷ market's volatility)

A stock with a yearly volatility of 30%, a correlation of 0.6 with Nifty, and Nifty's volatility at 14% has a market sensitivity of 0.6 × 30 ÷ 14 = 1.29. A ₹10 lakh position in it moves, on average, like ₹12.9 lakh of Nifty. To hedge that market exposure with Nifty futures, a trader would sell futures worth about ₹12.9 lakh, a little under one lot of 65 at 25,000. The hedge removes the market part of the risk; the part of the stock's moves that is not correlated with Nifty stays.

Indices and sectors in India

Most of the correlation an Indian trader meets comes from the market itself. Large-cap stocks are tied to Nifty, and the large indices are tied to each other: Nifty and Sensex hold many of the same companies and move almost together, so positions in both are close to one bet. Bank Nifty is a narrower basket of bank stocks; it is strongly correlated with Nifty because banks are a large part of Nifty, but it moves more on bank news and on interest rates.

Sector indices drift further apart. Information technology companies earn much of their revenue abroad and respond to the rupee and to overseas demand; fast-moving consumer goods companies tend to fall less in a broad sell-off; metal and energy companies follow world commodity prices. A portfolio spread across these sectors is less correlated than one spread across banks and financial companies alone. The matrix is the way to check that spread with numbers rather than labels: paste the sector indices you trade and see which pairs are truly different.

A worked example: checking a new position

A trader holds five stock positions of similar size: two private banks, a public sector bank, an IT company and a cement company. Before adding a sixth, a non-bank lender, the trader pastes 120 days of closes for all six into the tool.

The matrix shows the three banks with correlations between 0.7 and 0.85 among themselves, and the lender at 0.78 with the largest private bank. The IT company sits at 0.2 to 0.3 with everyone, the cement company at 0.4. The average correlation of the five current holdings is about 0.45; with the lender added, it rises to about 0.5, and four of the six positions now form one block.

The new position is not a new bet: it is a fourth version of the bank bet. The trader has three choices: add it at a smaller size, take it in place of one of the banks, or skip it. The matrix does not decide which; it shows that the decision is about concentration, not about one more stock.

Correlation for option traders

Option strategies on different indices can be the same trade in disguise. A trader who sells a weekly strangle on Nifty and another on Sensex is short volatility twice on two indices that move almost together. If the market makes a large move, both strangles lose at the same time. The same holds for a short straddle on Nifty and a short strangle on Bank Nifty on a day when banks lead the market.

Before running several option strategies at once, paste the daily closes of their underlyings into the tool. If the correlation is high, judge the combined position by its combined worst day, not by each strategy's own stop. QuantPower's account-level controls are built for this: the daily loss limit refuses new orders once the whole account's loss for the day reaches it, and Smart Exit squares off every position and stops the algos when the account's combined profit or loss hits its target or stop.

Correlating strategies, not just stocks

The same tool can compare strategies. Record each strategy's account value at the close of each day, put the strategy names in the first row and paste the daily values as if they were prices. The tool turns them into daily returns and shows how closely the strategies' results move together. Two algos that look different, such as a Nifty strangle and a Bank Nifty iron condor, may show a correlation of 0.8 in their daily results: in practice, one strategy run twice. The values must stay above zero for the log returns to work, so use account values, not daily P&L figures that can be negative.

Uses of a correlation matrix

Diversification

A portfolio of highly correlated stocks behaves like a single large position. Low correlations reduce the portfolio's overall volatility, as the table above shows.

Hedging

To reduce risk in a stock, look for a related instrument with high correlation, such as a sector index or a peer, that can be sold against it. The higher the correlation, the more of the risk the hedge removes.

Hidden concentration

Strategies that trade many stocks can end up with several positions in the same sector. A correlation check before adding a position shows whether it truly adds a new bet.

Pairs trading candidates

Highly correlated pairs are a starting point for pairs trading, but correlation alone is not enough. Pairs trading needs cointegration, a stable relationship between price levels. See the pairs cointegration tester and the pairs trading statistical arbitrage guide.

Choosing the window

The window decides what the matrix measures. Sixty trading days, about three months, shows the current relationship and reacts quickly to change. Two hundred and fifty days, about a year, is steadier but slow to notice that two stocks have drifted apart. Many traders look at both: a long window for the normal relationship, a short one to see whether today is normal.

A rolling correlation recalculates the figure each day over a moving window. Plotted over time, it shows how much a correlation wanders. Two bank stocks might sit near 0.8 for most of a year, dip to 0.5 in a month when one reports weak results, and jump above 0.9 on a day of market-wide selling. A single matrix is a snapshot of one window; check a second window before you act on it.

Correlation in calm and stressed markets

The same pair of stocks can show very different correlations in different kinds of market. In a calm, rising market, company news drives most daily moves, and correlations between stocks from different sectors are usually moderate. In a sharp fall, the market drives almost everything: foreign investors sell, margin calls force sales, and stocks across sectors fall on the same days. March 2020 and the sell-off of March 2026 both showed this in Indian markets. A matrix built only from calm months will understate how concentrated a portfolio becomes when it matters. If your window covers a stressed period, look at the matrix for that period on its own as well as for the whole window.

Pitfalls

  • Correlations change. A rolling correlation, recalculated each day over a moving window, shows how unstable they can be.
  • Correlations rise in crises. In sharp market falls, most stocks drop together, just when diversification is needed most.
  • Correlation is not causation. Two stocks can move together because both follow the market, not because they affect each other.
  • Outliers distort results. One extreme day, such as a result announcement, can change a correlation a lot over a short window.
  • Correlation measures linear relationships and can miss others.
  • Corporate actions break the price series. A split or a bonus issue halves or thirds the price overnight. Use prices adjusted for corporate actions, or the tool will see a crash that never happened.
  • Holidays and missing days. If one stock did not trade on a day, the row is dropped; check that the dates line up.

Correlation and cointegration

Correlation looks at returns: do the two stocks rise and fall on the same days? Cointegration looks at prices: does the gap between the two prices keep returning to a stable level? Two stocks can be highly correlated and drift apart for months, because a small difference in their daily moves adds up. Two stocks can also be cointegrated with only a moderate daily correlation, because their gap snaps back even though their days look different. A pairs trade bets on the gap returning, so it needs cointegration. A hedge or a diversification check needs correlation. The matrix is the first filter; the cointegration test is the second.

A checklist before you act on a correlation

  • Are the prices adjusted for splits, bonuses and other corporate actions?
  • Do the dates line up, with no missing days for any name?
  • Does the figure hold on a second window, both shorter and longer?
  • Is there a reason the two should move together, such as the same sector, the same customers or the same index?
  • Would the decision change if the correlation were 0.2 lower or higher?
  • How did the pair behave on the worst day in the window?

Using correlation in trading rules

  • Limit positions so that no two open trades have a correlation above a set level, such as 0.7.
  • Size positions by their contribution to portfolio risk rather than equally.
  • Re-check correlations regularly, since they drift.

Combine correlation checks with position sizing from the position size calculator and portfolio risk estimates from the VaR calculator. Write the correlation limit into the strategy's rules, so it is applied the same way every time.

Correlation checks in QuantPower

  • Multiple charts. Up to 16 charts on one screen, each with its own symbol and time frame, let you watch correlated stocks side by side.
  • Watchlists. Up to 20 lists of 100 scrips each, so a sector or a pair can sit in its own list.
  • Account-level risk. The daily loss limit, Smart Exit and the kill switch work on the combined position across every connected broker, which matters most when several positions are correlated and fall together.
  • Positions grouped by strategy. The positions screen can group legs by the algo that placed them, so two strategies that hold the same exposure are easy to spot.

Charts, the option chain, the screener and the strategy builder are free. A live algo costs 200 tokens per 28 days and a backtest 2 tokens, with the first 10 each week free (1 token = ₹1, GST extra). See pricing.

Common mistakes

  • Correlating prices instead of returns. Almost any two rising stocks look correlated on price.
  • Trusting one window. A correlation of 0.3 over 60 days can be 0.7 over a year.
  • Treating low correlation as safety. Correlations rise when markets fall.
  • Ignoring the size of moves. Two stocks with a correlation of 0.9 can still lose very different amounts if one is far more volatile.
  • Forgetting the index. Most Indian stocks are correlated with Nifty; a portfolio of "uncorrelated" stocks can still be one large bet on the market.

Where correlation analysis is going

Correlation matrices were once a task for a spreadsheet and an evening. Today they can be built in seconds, for hundreds of stocks, on any window. The questions have not changed: which of my positions are really the same bet, and what happens to them on a bad day. The pitfalls have not changed either. A larger matrix finds more pairs that look related by chance, so the discipline of checking a second window and asking why two stocks should move together matters more as the data grows. The same applies to strategies: as more traders run several algos at once, the correlation between strategies' daily results is becoming as important a check as the correlation between the stocks they trade.

Start with 500 free tokens

Connect your broker, build a strategy and test it on paper before a single live order goes out.

Frequently asked questions

What is a correlation matrix in stocks?

A table showing the correlation of returns between each pair of stocks in a group.

Should I use prices or returns?

Returns. Price levels can show high correlation even when daily moves are unrelated.

What correlation is good for diversification?

Lower is better for diversification. Stocks with correlations below about 0.3 add more diversification than those above 0.7.

Is high correlation enough for pairs trading?

No. Pairs trading needs cointegration, which tests whether the price gap returns to a stable level.

How many days of prices do I need?

The tool needs at least ten rows, but that is only enough to see how it works. Sixty trading days gives a usable short-term figure and two hundred and fifty a yearly one. For a decision about a real position, check both and see whether they agree.

Can I include an index in the matrix?

Yes. Add a column for Nifty or a sector index with its daily closes. The stock's correlation with the index is the starting point for its market sensitivity.

Why does the tool use log returns?

Log returns add up across days, treat rises and falls symmetrically, and for daily moves of a few per cent give almost the same correlation as simple percentage returns. They are the usual choice in finance for these reasons.

References

  1. Pearson, K. (1896). Mathematical Contributions to the Theory of Evolution. III. Regression, Heredity, and Panmixia. Philosophical Transactions of the Royal Society A, 187, 253–318; Galton, F. (1888). Co-relations and their Measurement. Proceedings of the Royal Society, 45, 135–145
  2. Markowitz, H. (1952). Portfolio Selection. Journal of Finance, 7(1), 77–91
  3. Longin, F. and Solnik, B. (2001). Extreme Correlation of International Equity Markets. Journal of Finance, 56(2), 649–676
  4. Sharpe, W. F. (1964). Capital Asset Prices: A Theory of Market Equilibrium under Conditions of Risk. Journal of Finance, 19(3), 425–442
The matrix and figures on this page are illustrations. Trading involves substantial risk. This tool and guide are for education and are not investment advice.