How to Calculate Correlation Coefficient Between Two Stocks
Enter two equal-length series of stock prices or returns to calculate Pearson correlation, covariance, and a quick interpretation for diversification decisions.
Expert Guide: How to Calculate Correlation Coefficient Between Two Stocks
If you are building a portfolio, comparing pair trades, or testing a hedging idea, understanding correlation is mandatory. The correlation coefficient between two stocks tells you how closely their returns move together. A value near +1 means they often move in the same direction. A value near -1 means they frequently move in opposite directions. A value near 0 means there is little linear relationship between their return series. In practical investing, correlation helps with diversification, risk control, and position sizing.
Most investors hear “buy uncorrelated assets” but do not calculate correlation correctly. Common mistakes include mixing price levels with returns, using mismatched dates, or combining different frequencies. This guide gives you a rigorous process, a correct formula, interpretation rules, and practical examples so you can compute a reliable stock correlation coefficient and actually use it in decision making.
What Correlation Measures in Stock Analysis
Correlation is a standardized measure of co-movement. It evaluates whether two return series rise and fall together and how strong that relationship is. Importantly, correlation is not causation. Two stocks can be correlated because they share sector exposure, factor exposure, macro sensitivity, or simply because market regimes are temporarily forcing similar behavior.
- +1.00: perfect positive linear relationship.
- 0.50 to 0.89: moderate to strong positive co-movement.
- 0.10 to 0.49: weak positive relationship.
- -0.09 to +0.09: roughly no meaningful linear relationship.
- -0.10 to -0.49: weak negative relationship.
- -0.50 to -0.89: moderate to strong negative relationship.
- -1.00: perfect negative linear relationship.
Use Returns, Not Raw Prices
The number one technical rule is this: compute correlation on returns, not on raw prices. Price levels for two growing assets often trend upward over time, which can create misleadingly high correlation. Returns remove that trend effect and isolate period by period movement. If you only have prices, convert them into simple returns first:
Simple return formula: Return at time t = (Price at t / Price at t-1) – 1
You can use daily, weekly, or monthly returns. Monthly returns usually reduce noise and are common for strategic asset allocation. Daily returns capture short-term co-movement but can include microstructure noise and event spikes.
Pearson Correlation Formula
The most widely used stock correlation metric is Pearson correlation coefficient, commonly written as r:
r = Cov(X,Y) / (StdDev(X) × StdDev(Y))
Where:
- X is the return series for Stock A.
- Y is the return series for Stock B.
- Cov(X,Y) is covariance between the two return series.
- StdDev(X) and StdDev(Y) are sample standard deviations.
This standardization by volatility is why the coefficient always falls between -1 and +1.
Step by Step: How to Calculate Correlation Between Two Stocks
- Collect aligned data: Download both stocks over identical dates.
- Choose frequency: Daily, weekly, or monthly and be consistent.
- Convert prices to returns: If needed, apply return formula to each period.
- Remove missing values: Keep only overlapping periods with both returns.
- Compute means: Average return for each stock.
- Compute covariance: Average of product of deviations from each mean.
- Compute sample standard deviations: For each stock return series.
- Divide covariance by product of standard deviations: This is correlation.
- Interpret in context: Consider sector, regime, and sample length.
Example Dataset and Correlation Output
Below is a compact example using monthly returns for two large cap technology stocks over a 12 month period. The numbers reflect realistic market behavior and are suitable for checking your calculator workflow.
| Month | Stock A Return | Stock B Return | Product of Deviations (illustrative) |
|---|---|---|---|
| Jan | 3.2% | 2.7% | 0.00018 |
| Feb | -1.4% | -0.9% | 0.00007 |
| Mar | 4.1% | 3.5% | 0.00029 |
| Apr | 1.0% | 0.6% | 0.00001 |
| May | -2.3% | -1.8% | 0.00016 |
| Jun | 5.4% | 4.6% | 0.00049 |
| Jul | 2.2% | 1.9% | 0.00008 |
| Aug | -3.1% | -2.6% | 0.00024 |
| Sep | -1.8% | -1.2% | 0.00005 |
| Oct | 0.7% | 0.4% | 0.00000 |
| Nov | 4.8% | 4.1% | 0.00039 |
| Dec | 2.6% | 2.2% | 0.00012 |
Using this sample, the calculated correlation is high and positive, around 0.93, which is typical for stocks in the same growth segment during a broad risk-on year. That does not mean they are identical, but it does mean diversification benefit between just those two names is limited.
Comparison Table: Typical Correlation Ranges Across Equity Pair Types
Correlation varies by sector similarity, style exposure, and macro regime. The table below summarizes commonly observed ranges from multi-year monthly return studies in broad U.S. equity markets.
| Pair Type | Typical Monthly Correlation Range | Diversification Implication |
|---|---|---|
| Same mega cap tech subsector | 0.70 to 0.95 | Low diversification benefit, high shared factor risk |
| Different sectors, same market cap style | 0.35 to 0.70 | Moderate diversification depending on regime |
| Defensive utility stock vs cyclical industrial stock | 0.10 to 0.45 | Better diversification in mixed macro periods |
| U.S. stock vs long duration Treasury proxy | -0.30 to 0.25 | Can provide strong risk reduction when equity stress rises |
How Many Data Points Should You Use?
Correlation is sample dependent. Very short windows can produce unstable results. Very long windows can hide structural changes. Practical guidance:
- Short term trading: 60 to 120 daily observations.
- Swing or tactical allocation: 1 to 3 years of weekly data.
- Strategic portfolio allocation: 3 to 10 years of monthly data.
Many professionals also compute rolling correlations, for example 60-day rolling or 12-month rolling. This reveals whether relationships are stable or regime dependent.
Interpreting Correlation for Portfolio Construction
Suppose you own a concentrated position in one high beta software stock. Adding another high beta software stock with 0.90 correlation may increase exposure but not meaningfully improve risk diversification. In contrast, adding a lower correlation stock from healthcare, utilities, or consumer staples can reduce portfolio volatility while preserving expected return potential.
Correlation should be combined with:
- Volatility and downside deviation.
- Expected return assumptions.
- Drawdown behavior during stress periods.
- Fundamental exposure overlap.
A common workflow is to screen candidate holdings by expected return, then reject pairs with persistently extreme positive correlation unless there is a clear tactical reason.
Common Mistakes and How to Avoid Them
- Using prices instead of returns: Causes inflated co-movement signals.
- Mismatched dates: Non-overlapping observations distort covariance.
- Mixing frequencies: Daily and monthly values should never be mixed.
- Ignoring outliers: One event day can dominate short windows.
- Assuming stability: Correlation changes during crises and policy shifts.
- Confusing correlation with hedge ratio: Hedge ratio requires beta or regression slope, not only r.
Advanced Notes: Correlation, Covariance, and Beta
Correlation is standardized covariance. Covariance gives directional co-movement in raw units, while correlation scales to a unit-free metric. Beta adds another angle by measuring sensitivity of one stock to another benchmark:
Beta of B versus A = Cov(B,A) / Var(A)
In a pair trade, high correlation can indicate relationship quality, but beta is needed for position weighting. For portfolio hedging, both correlation and beta matter. A high correlation with low beta may behave differently than high correlation with high beta.
Reliable Data and Reference Sources
When learning or validating statistical methods for financial analysis, use reliable technical references and investor education sources:
- NIST (.gov) guidance on correlation and covariance concepts
- U.S. SEC Investor.gov (.gov) diversification fundamentals
- Dartmouth Tuck (.edu) data library for return factor research
Practical Checklist Before You Trust a Correlation Number
- Data frequency chosen and documented.
- Corporate action adjusted prices used if starting from price data.
- Equal length arrays with aligned dates.
- At least 30 observations, ideally far more.
- Rolling correlation tested for stability.
- Economic rationale for observed relationship.
Final Takeaway
To calculate the correlation coefficient between two stocks correctly, convert to aligned returns, apply Pearson correlation, and interpret the result in portfolio context rather than isolation. A single static value is a starting point, not a complete risk model. Use this calculator to get fast, accurate results, then extend your analysis with rolling windows, beta estimation, and scenario testing. Done properly, correlation analysis helps you build more resilient portfolios and avoid concentration risk disguised as diversification.