Sub topic 3
Correlation: why holdings that move differently help
This chapter assumes you know what stocks, funds, and ETFs are, how to compute a percentage return and a simple average, and that higher expected return usually comes with higher risk. It also assumes you have met the idea of volatility (the standard deviation of returns) and the split between systematic and idiosyncratic risk from earlier chapters. The new idea here is correlation. It is the number that decides how much risk disappears when you combine two holdings.
What correlation measures
Correlation describes how closely two return series move together. It is a number between -1 and +1.
- +1 means the two returns move in perfect lockstep. When one is above its average, the other is too, in proportion.
- 0 means there is no linear relationship. Knowing one return tells you nothing useful about the other.
- -1 means the returns move in exact opposite directions around their averages.
The formal definition starts from covariance. Covariance is the average product of the two assets' deviations from their own average returns. Correlation rescales covariance by both volatilities so the result always lands between -1 and +1:
correlation(A, B) = covariance(A, B) / (volatility(A) * volatility(B))Rescaling matters because covariance depends on units and on how volatile each asset is. Correlation isolates the pattern of co-movement from the size of the moves.
Two details are easy to miss:
- Correlation is computed on returns, not prices. Two prices that both trend upward over years will look strongly correlated even when their monthly returns are unrelated. This is a common source of false "evidence" of correlation.
- Correlation says nothing about magnitude. A stock that moves 1% when the market moves 10% can still have a correlation near +1 with it.
Computing it from data
The function below uses only the standard library. It is meant to show the formula, not to be a production tool. Four observations are far too few to estimate a real correlation.
import math
def correlation(a, b):
n = len(a)
mean_a = sum(a) / n
mean_b = sum(b) / n
cov = sum((x - mean_a) * (y - mean_b) for x, y in zip(a, b))
var_a = sum((x - mean_a) ** 2 for x in a)
var_b = sum((y - mean_b) ** 2 for y in b)
return cov / math.sqrt(var_a * var_b)
stock_a = [0.02, -0.01, 0.03, -0.02]
stock_b = [0.015, -0.015, 0.025, -0.005]
print(round(correlation(stock_a, stock_b), 2))
# 0.92The factors of 1/n cancel between the numerator and denominator, so summing without dividing gives the same correlation. In practice you would use numpy.corrcoef or pandas.DataFrame.corr on a long history of returns.
Why low correlation lowers portfolio risk
Take two assets with weights w1 and w2, volatilities s1 and s2, and correlation rho. The portfolio's variance is:
variance = (w1*s1)^2 + (w2*s2)^2 + 2 * w1 * w2 * s1 * s2 * rhoThe first two terms are what each holding contributes on its own. The last term is the interaction. It grows with rho and shrinks as rho falls. When rho is +1, the formula collapses to a plain weighted average of the two volatilities, so there is no benefit at all. For any rho below +1, the portfolio's volatility is lower than that weighted average.
This is the whole mechanism. Expected return of the mix is just the weighted average of the two expected returns, whatever the correlation is. Volatility is not a weighted average. Correlation below 1 lets some of each asset's ups and downs offset the other's. The result is the same expected return with less variation.
For a 50/50 mix of two assets that each have 20% volatility, the formula simplifies to vol = 0.20 * sqrt((1 + rho) / 2):
| Correlation (rho) | Portfolio volatility |
|---|---|
| +1.0 | 20.0% |
| +0.8 | 19.0% |
| +0.5 | 17.3% |
| +0.3 | 16.1% |
| 0.0 | 14.1% |
| -0.5 | 10.0% |
| -1.0 | 0.0% |
The curve is concave. Moving correlation from +1 to +0.8 buys only about one point of volatility reduction. Moving it from +0.3 to -0.5 buys six. Most real stock pairs sit in the upper part of the chart, so the practical gains come from finding holdings whose correlation is meaningfully below that range.
A mixed-volatility example
The two assets rarely have equal volatility. Consider a stock fund with 25% volatility and a bond fund with 8% volatility, correlation 0.1, held 60/40.
import math
def portfolio_vol(w1, s1, s2, rho):
w2 = 1 - w1
variance = (w1 * s1) ** 2 + (w2 * s2) ** 2 + 2 * w1 * w2 * s1 * s2 * rho
return math.sqrt(variance)
weighted_average = 0.6 * 0.25 + 0.4 * 0.08
actual = portfolio_vol(0.6, 0.25, 0.08, 0.1)
print(round(weighted_average, 4))
print(round(actual, 4))
# 0.182
# 0.1565A simple weighted average would suggest 18.2% volatility. The correlation-adjusted figure is 15.65%. The gap of about 2.5 points is the diversification effect, and it comes entirely from the correlation term being small.
From two assets to many
With n assets the portfolio variance is the sum of every pairwise covariance term weighted by the product of the two weights. The number of pairs grows roughly with the square of n, so the pairwise correlations matter far more than any single holding's volatility once you hold many positions. Adding a stock helps only if its correlation with what you already own is lower than the portfolio's existing average correlation.
For an equal-weight portfolio where every stock has volatility sigma and every pair has the same correlation, the formula reduces to this:
import math
def equal_weight_vol(n, sigma, avg_rho):
variance = sigma ** 2 * (1 / n + (1 - 1 / n) * avg_rho)
return math.sqrt(variance)
for n in (1, 5, 20, 100, 1000):
print(n, round(equal_weight_vol(n, 0.30, 0.30), 4))
# 1 0.3
# 5 0.2145
# 20 0.1777
# 100 0.1657
# 1000 0.1645The 1 / n term shrinks toward zero as you add stocks. The correlation term does not. As n grows, volatility approaches sigma * sqrt(avg_rho), here about 16.4%. That floor is the part of risk shared across the holdings, which is the systematic risk from the previous chapter. The next chapters ask how many stocks you need to get near that floor.
What correlation does not tell you
Correlation is a useful summary but a limited one. Keep these errors in mind.
- It captures only linear co-movement. Two assets can have a correlation near zero and still crash together, because the relationship is non-linear or only appears in extreme moves.
- It is an estimate, and a noisy one. With 36 monthly observations and a true correlation of 0.5, the standard error is roughly 0.13. The estimate could plausibly land anywhere from about 0.25 to 0.75. Comparing two measured correlations of 0.4 and 0.5 is mostly comparing noise.
- It depends on the window and the frequency. Daily, monthly, and annual returns give different estimates for the same pair. A five-year window and a twenty-year window can disagree.
- It is not stable over time. Correlations between stocks, and between stocks and other assets, tend to rise in sharp market sell-offs, exactly when you wanted the offset. The "What diversification cannot do" chapter returns to this.
- It is not causation. Two sectors can be correlated because they respond to the same driver, such as interest rates or oil prices, not because one affects the other. Knowing the driver is more useful than knowing the number.
Practical checks
When you review a portfolio, use correlation as a screening tool:
- Ask whether the holdings share a common driver. Two software companies, or two banks in the same country, usually have high correlation because they respond to the same demand, rates, and regulation.
- Prefer a long history and a stated frequency, usually monthly returns over several years, and note that the figure is approximate.
- Look at how correlation behaved in past stress periods, not only the full-sample average.
- Remember that cheap diversification comes from assets with low but positive correlation. Strongly negative correlation is rare among stocks, and you should not plan around finding it.
Exercise
Two stocks each have 30% volatility and are held 50/50. Calculate the portfolio volatility when their correlation is 0.6. Use vol = sigma * sqrt((1 + rho) / 2), which holds for equal weights and equal volatilities. Is it above or below 30%, and why?
Show answer
vol = 0.30 sqrt((1 + 0.6) / 2) = 0.30 sqrt(0.8) = 0.30 * 0.8944, which is about 0.2683, or 26.8%. It is below 30% because the correlation is below +1, so part of each stock's movements offsets the other's. If the correlation were exactly +1, the result would be 30% and there would be no diversification benefit.
Exercise
A portfolio holds 40 stocks. Each has 25% volatility and the average pairwise correlation is 0.4. Using the equal-weight formula variance = sigma^2 (1/n + (1 - 1/n) avg_rho), what volatility does the portfolio approach if you add more and more stocks, and why can't you go lower by adding stocks alone?
Show answer
As n grows, the 1/n term goes to zero and the variance approaches sigma^2 avg_rho = 0.0625 0.4 = 0.025. The volatility approaches sqrt(0.025), about 15.8%. Adding more stocks cannot push it lower because the remaining risk comes from the average correlation, which is the shared market-wide component. Lowering it requires holdings with lower correlation to each other, not simply more holdings.