Quant from Scratch by QuantWright

Introduction to Quant Finance · Lesson 11

Correlation and diversification

One number for how closely two series move together. It decides how much mixing two assets lowers risk; it sees straight lines only, and it says nothing about cause.

Know the basics? Read the lesson notes

Five days, two assets

A day's return is what an asset gained or lost that day, in percent. Over five simulated days, asset X returned +2%, −1%, +3%, 0% and +1%, and asset Y returned −1%, −3%, +5%, +1% and +3%. Both averaged +1%: 5 ÷ 5.

A scatter plot draws each day as one dot: across for X's return, up for Y's. The dashed lines mark the two averages. Tap each day.

Five days of X and Y (simulated)

Each dot is a day. The box from the averages' crossing to the dot has sides equal to the two distances from the averages; colour: their product is positive; grey: negative.

Day–
Distances from the averages–
Product–

A day when X and Y land on the same side of their averages, both above or both below, gives a positive product. Opposite sides give a negative one, and a day on an average line gives 0. The five products are −2, +8, +8, 0 and 0, which add up to 14.

Divide by 5 − 1 = 4, the way a sample's standard deviation (how far numbers typically land from their average) divides by n − 1 when a few days stand in for many more, and you get 3.5: the covariance. It is positive, so X and Y tended to land on the same side together. But 3.5 is in "percent times percent", and it grows with the size of the moves, so on its own it can't say how close the link is.

Theory

Covariance and correlation

Divide the covariance by both standard deviations and the units cancel. What is left is the correlation coefficient (Pearson's), usually just the correlation: a number from −1 to +1. At +1 the dots lie on a rising straight line, at −1 on a falling one, and at 0 there is no straight-line link.

cov = [(x1 − μx)(y1 − μy) + … + (xn − μx)(yn − μy)] ÷ (n − 1)
ρ = cov ÷ (sx × sy)
x1 … xn, y1 … yn
the paired numbers, one pair a day; n is how many pairs
μx, μy
"mu", the average: their averages
sx, sy
their sample standard deviations: how far each typically lands from its average, dividing by n − 1
cov
the covariance: the average product of the two distances from the averages, dividing by n − 1
ρ
"rho", the correlation: from −1 to +1; it measures a straight-line link only
Worked example: your five days

cov = 14 ÷ 4 = 3.5. X's distances +1, −2, +2, −1, 0 square to 1, 4, 4, 1, 0, which add up to 10: 10 ÷ 4 = 2.5, so sx = √2.5 ≈ 1.58%. Y's distances −2, −4, +4, 0, +2 square to 4, 16, 16, 0, 4, which add up to 40: 40 ÷ 4 = 10, so sy = √10 ≈ 3.16%. Their product is √(2.5 × 10) = √25 = 5, so ρ = 3.5 ÷ 5 = 0.7.

Double every one of Y's returns and the covariance and sy both double, so ρ stays 0.7. Correlation says how closely the dots follow a straight line, not how steep the line is.

Holds when
  • you want the strength of a straight-line link between two series;
  • there are enough pairs;
  • the link stays the same over the whole sample.
Breaks when

The link is curved (later in this lesson). One extreme day moves it a lot, because its distances are multiplied (real returns often have more extreme days than a bell curve; the Fat tails lesson covers this). If the link is stronger in wild spells than in calm ones, one number for the whole sample hides it.

New numbers. Over three days X returned +1%, +2% and +3%, and Y returned +2%, 0% and +4%. What is their correlation?

Both average 2%. Distances: X −1, 0, +1; Y 0, −2, +2. Products: 0, 0, +2, so cov = 2 ÷ 2 = 1. sx = √(2 ÷ 2) = 1 and sy = √(8 ÷ 2) = 2. ρ = 1 ÷ (1 × 2) = 0.5.

Drag the correlation

Two simulated assets, X and Y, over 250 days. Each day's return has a standard deviation of 1%, and the days were built to have exactly the correlation you set. Each price starts at 100 and compounds: every day it grows or shrinks by that day's return. Drag it to 1, to 0 and to −1.

X and Y at the correlation you set (simulated)

Top: one dot a day. Below: the two prices, both starting at 100. Dark: X. Colour: Y.

Correlation0.50
Days both moved the same way–

At 1 the dots lie on one rising line and the two prices move as one: X and Y moved the same way on all 250 days. At −1 the line falls and the prices mirror each other: 0 days. At 0 the dots make a round cloud and the prices wander apart: 124 days, about half.

Guess the correlation

Three more simulated pairs of 100 days, built with correlations of −0.6, 0.3 and 0.9, one each. Pick the correlation you think each scatter has.

Three pairs, 100 days each (simulated)

Pair A

Pair B

Pair C

Pair A was 0.3, pair B −0.6 and pair C 0.9. A correlation of 0.3 still looks like a round cloud with a slight lean; it takes about 0.9 before the dots form a tight band.

Two 10% risks, how big together?

Two simulated assets. Each one's yearly return has a standard deviation of 10%: its volatility, the usual name for the standard deviation of an asset's returns. Picture an account that holds half of each, reset to half and half at the start of every year (called rebalancing). This 50/50 mix's yearly return is half of one asset's return plus half of the other's. Guess first: if the two assets have a correlation of 0, what is the mix's volatility?

10,000 simulated years of the 50/50 mix

Each column counts the years whose return landed in a range 2.5% wide. Shaded: 0%, the average return, ± one standard deviation. At −1 every year lands on 0%, so the band has no width.

Your guess:
Correlation:
Correlation–
The mix's volatility–

Across the 10,000 simulated years the mix's volatility was 9.86% at a correlation of 1, 7.03% at 0 and 0% at −1.

At 1 the two assets rise and fall together, so the mix is as risky as either one alone. At −1 one asset's gain is always the other's loss, and, being the same size, the two halves cancel. At 0 they partly cancel.

Theory

The volatility of a 50/50 mix

Lowering risk by mixing things that don't move as one is called diversification. In any one year, call the two assets' distances from their average returns d1 and d2. The mix's distance is ½d1 + ½d2, and its square is ¼d1² + ¼d2² + ½ × d1 × d2 (the middle term is 2 × ½ × ½ = ½). Averaged over many years, d1² gives σ1², d2² gives σ2², and d1 × d2 gives the covariance, which is ρ × σ1 × σ2 (the correlation formula turned around). Take the square root:

σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2)
σ1, σ2
"sigma", the two assets' volatilities: the standard deviations of their returns
ρ
the correlation of their returns
σmix
the volatility of a mix holding half of each, if ρ is the same throughout
Worked example: your two 10% assets

σ1 = σ2 = 10, so ¼ × 100 = 25 twice, and ½ × ρ × 10 × 10 = 50ρ: σmix = √(25 + 25 + 50ρ).

ρ = 1: √100 = 10%. ρ = 0.5: √75 ≈ 8.66%. ρ = 0: √50 ≈ 7.07%. ρ = −0.5: √25 = 5%. ρ = −1: √0 = 0%.

Below 1, the mix is less risky than either asset: that is the gain from diversification. Near 1 it fades: at ρ = 0.9, √95 ≈ 9.75%, barely below 10%. The simulation measured 9.86%, 7.03% and 0%: 10,000 years are still a sample, so its first two land a little off the formula's 10% and 7.07%.

Holds when
  • the two volatilities and the correlation are the true ones, or well measured (a later card shows how far a short sample's correlation can be off);
  • the correlation is the same in calm and wild spells;
  • the mix is reset to half and half each time.
Breaks when

If the correlation is higher in wild spells than the number put in, the mix is riskier than the formula says.

New numbers. Two assets have volatilities of 6% and 8% and a correlation of 0.5. What is the volatility of a 50/50 mix, in percent?

¼ × 36 + ¼ × 64 + ½ × 0.5 × 6 × 8 = 9 + 16 + 12 = 37, and √37 ≈ 6.08%. At a correlation of 1 it would be √(9 + 16 + 24) = √49 = 7%, halfway between 6 and 8; at 0, √(9 + 16) = 5%.

Straight lines only

Now a pair with a perfect link that isn't straight. Asset X's day is a bell-curve draw (most days near the average, fewer far out) with a standard deviation of 1%. Series Y's day is X's return in percent, squared, minus 1: on a day X moves 2% either way, Y is 2 × 2 − 1 = +3%. Y is fully set by X.

X and Y, 250 days (simulated)

Y = X × X − 1, with X in percent: X at +2% or −2% gives Y at +3%.

What is the correlation of these 250 days?

It is −0.05. For every dot at +x there is roughly a mirror dot at −x with the same Y, and their products have opposite signs, so they cancel.
It is −0.05. For every dot at +x there is roughly a mirror dot at −x with the same Y, and their products have opposite signs, so they cancel.
It is −0.05. Y is fully set by X, but not along a straight line: for every dot at +x there is roughly a mirror dot at −x with the same Y, and their products have opposite signs, so they cancel.

Not one sample's luck: across 1,000 simulated samples of 250 days, the correlation averaged 0.00 and landed between −0.3 and 0.3 in 978. A correlation near 0 means no straight-line link, not no link.

A short sample is noisy

Take two simulated series with nothing between them: each day of each is its own bell-curve draw, so their true correlation is 0. Guess first: of 1,000 samples of 20 days, how many measure a correlation of 0.3 or more, or −0.3 or less? Then look at 20 days and at 250.

1,000 samples of each length, true correlation 0 (simulated)

Each column counts the samples whose measured correlation landed in a range 0.05 wide. Colour: 0.3 or more either way.

Your guess:
Days in a sample:
The middle 950 of 1,000–
0.3 or more either way–

In this simulation, of the 1,000 samples of 20 days, 190 measured 0.3 or more either way, and the middle 950 ran from −0.45 to 0.44. Of the 1,000 samples of 250 days, 0 did, and the middle 950 ran from −0.13 to 0.12.

More days, more of the luck cancels.

Moving together, not moving each other

Two more simulated assets. Each day, X moves by a "market" move plus a move of its own, and Y moves by the same market move plus a move of its own. All three moves are separate bell-curve draws of the same size, so each asset is half market, half its own: half its movement is shared, and the true correlation is 0.5. Neither asset ever sees the other's move, yet over these 250 days they measured a correlation of 0.37, and over 1,000 such samples 0.50 on average.

X and Y, 250 days (simulated)

Correlation, these 250 days–

Take the market move out of both, leaving each asset's own move. What will their correlation be?

The market move was all they shared. What is left are two separate draws, with a true correlation of 0.
The market move was all they shared. What is left are two separate draws, with a true correlation of 0.
Taking out a shared move removes the link; it doesn't turn it around. What is left are two separate draws, with a true correlation of 0.

With the market move taken out, these 250 days measured −0.09; the 1,000 simulated samples averaged 0.00, and 0 of them measured 0.3 or more either way, against 999 before.

A correlation can't tell X moving Y from Y moving X, or from a third series moving both. The textbook name for such a third series is a confounder: correlation is not causation.

One more word: beta, how far one series tends to move for each 1% the other moves, the steepness the correlation leaves out. For the five days at the start, the covariance divided by X's standard deviation squared gives 3.5 ÷ 2.5 = 1.4: Y tended to move 1.4% for each 1% of X, with a correlation of 0.7. The Regression lesson works it out properly.

What this means for your backtest

A backtest runs a trading rule over past prices to see what it would have made. When you run two rules, or compare a rule with a market, correlation comes in. Three habits follow.

  1. Ask which correlation a mix's risk assumed.

    A 50/50 mix of two 10% assets is 10% at a correlation of 1 and about 7% at 0. Mixing lowers risk only as far as the correlation sits below 1, and only while it stays there.

Practice 1 of 2

"14% of risk"

The situationA friend's account holds half in rule F and half in rule G, reset to half and half each year. F's yearly return has a volatility of 12% and G's 16%, and over six years of daily results the two measured a correlation of 0.25 (assume daily returns are independent, so the yearly returns share it). The friend says the account's volatility is 14%, the average of the two.

If the correlation stays at 0.25, what is the volatility of the account's yearly return, in percent?

Hint: σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2) with 12, 16 and 0.25.

¼ × 144 + ¼ × 256 + ½ × 0.25 × 12 × 16 = 36 + 64 + 24 = 124, and √124 ≈ 11.14%. The friend's 14% is right only at a correlation of 1: √(36 + 64 + 96) = √196 = 14.
Practice 2 of 2

"X drives Y"

The situationA forum post: "Over the last 20 days, asset X and asset Y had a correlation of 0.4. So X's moves push Y."

What can those 20 days tell you?

In the lesson's simulation, 20-day samples of two series with nothing between them landed from −0.45 to 0.44 in 950 of 1,000, so 0.4 is inside what luck gives. And even a real link could come from a shared driver.
0.4 sits inside the −0.45 to 0.44 that held 950 of 1,000 twenty-day samples of two unrelated series in the lesson's simulation. And even a real correlation can't say which moves which, or whether a third series moves both.
Correlation says how closely the dots follow a straight line, not how steep the line is: doubling Y's moves leaves it unchanged. How far Y tends to move per 1% of X is its beta. And 0.4 over 20 days is inside what luck gives two unrelated series.
✓

Lesson done

The correlation measures how closely two series follow a straight line together, from −1 to +1: their covariance divided by both standard deviations. It decides how much mixing lowers risk: if the correlation stays the same throughout, a 50/50 mix's volatility is the average of the two only at a correlation of 1, less below it, and 0% at −1 for two equally volatile assets. It sees straight-line links only, not how steep the line is (that is beta); a short sample's figure is noisy (in this lesson's simulation, 20-day samples of unrelated series landed from −0.45 to 0.44 in 950 of 1,000); and it can't say which series moves which.

Key ideas

Scatter plot
a chart of pairs, one dot each: across for one series, up for the other
Covariance
the average product of two series' distances from their averages, dividing by n − 1; positive when they tend to land on the same side of their averages together
Correlation
the covariance divided by both standard deviations: from −1 to +1, the strength of a straight-line link only, for that sample
Beta
how far one series tends to move for each 1% the other moves: the steepness of the line, which the correlation leaves out
Diversification
lowering risk by mixing things that don't move as one; for a 50/50 mix it is largest at a correlation of −1 and gone at 1, if the correlation is the same throughout
Confounder
a third series that moves two others, giving them a correlation though neither moves the other

Formulas

cov = sum of (x − μx)(y − μy) ÷ (n − 1) · ρ = cov ÷ (sx × sy)

σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2)

The second formula, for a mix holding half of each, needs a correlation that stays the same throughout; a measured one carries its sample's noise.

Lesson notes

The correlation measures how closely two series follow a straight line together, on a scale from −1 to +1: their covariance (the average product of their distances from their averages) divided by both standard deviations (how far each typically lands from its average). It decides how much mixing two assets lowers risk: a half-and-half mix of two assets whose volatilities (the standard deviations of their returns) are σ1 and σ2 has a volatility of √(¼σ1² + ¼σ2² + ½ρσ1σ2), which is the average of the two volatilities only at a correlation of 1 and less below it, if the correlation stays the same throughout. It sees straight-line links only, a short sample's figure is noisy, and it can't say which series moves which. Every count below is from the lesson's simulation, in which a computer draws every day.

Covariance from five days

A day's return is what an asset gained or lost that day, in percent. Over five simulated days, asset X returned +2%, −1%, +3%, 0% and +1%, and asset Y returned −1%, −3%, +5%, +1% and +3%; both averaged +1%. A scatter plot draws each day as a dot: across for X's return, up for Y's. Each day's distances from the two averages are, for X, +1, −2, +2, −1 and 0, and for Y, −2, −4, +4, 0 and +2. Multiply each day's pair: a day when both land on the same side of their averages gives a positive product, opposite sides a negative one, and a day on an average a 0. The five products are −2, +8, +8, 0 and 0, which add up to 14. Divided by 5 − 1 = 4 (a sample divides by n − 1, as a sample standard deviation does, because a few days stand in for many more), that is 3.5: the covariance. Positive, so X and Y tended to land on the same side together. But it is in "percent times percent" and grows with the size of the moves, so on its own it can't say how close the link is.

From covariance to correlation

Dividing the covariance by both sample standard deviations cancels the units and gives the correlation (Pearson's correlation coefficient), written ρ, "rho". For the five days: sx = √(10 ÷ 4) ≈ 1.58%, sy = √(40 ÷ 4) ≈ 3.16%, their product is √25 = 5, and ρ = 3.5 ÷ 5 = 0.7. At +1 the dots lie on a rising straight line, at −1 on a falling one, and at 0 there is no straight-line link. Doubling every one of Y's returns doubles the covariance and sy alike, so ρ stays 0.7: correlation says how closely the dots follow a straight line, not how steep it is. The steepness is called beta: how far Y tends to move for each 1% that X moves. For the five days it is the covariance divided by X's standard deviation squared, 3.5 ÷ 2.5 = 1.4; the Regression lesson, later in the course, works it out properly.

In a simulated pair of 250 days built to have exactly a chosen correlation, each day with a standard deviation of 1%, X and Y moved the same way on all 250 days at a correlation of 1, on 124 at 0, and on 0 at −1, where their prices mirrored each other. Three more simulated pairs of 100 days, built with correlations of 0.3, −0.6 and 0.9, showed that 0.3 still looks like a round cloud with a slight lean, and that it takes about 0.9 before the dots form a tight band.

Mixing two assets

An asset's volatility is the standard deviation of its returns. Two simulated assets each had a yearly volatility of 10%, and an account held half of each, reset to half and half every year (rebalancing), so this 50/50 mix's yearly return was half of one asset's plus half of the other's. In 10,000 simulated years the mix's volatility was 9.86% at a correlation of 1, 7.03% at 0 and 0% at −1 (the formula below gives 10%, 7.07% and 0%; 10,000 years are still a sample, so the first two land a little off). At 1 the assets rise and fall together, so the mix is as risky as either alone; at −1 one asset's gain is always the other's loss, and the two halves cancel; at 0 they partly cancel. Lowering risk by mixing things that don't move as one is diversification. The reason: in any year, call the two assets' distances from their average returns d1 and d2. The mix's distance is ½d1 + ½d2, whose square is ¼d1² + ¼d2² + ½ × d1 × d2 (2 × ½ × ½ = ½). Averaged over many years, d1² gives σ1² and d2² gives σ2² (σ, sigma, is an asset's volatility), so these terms give ¼σ1², ¼σ2² and half the covariance, and the covariance is ρ × σ1 × σ2.

The gain fades as the correlation nears 1: two 10% assets at a correlation of 0.9 give a mix of √95 ≈ 9.75%, barely below 10%.

What correlation misses

Curved links. Asset X's day was a bell-curve draw with a standard deviation of 1%, and series Y's day was X's return in percent, squared, minus 1, so Y was fully set by X. Across 1,000 simulated samples of 250 days, the correlation averaged 0.00 and landed between −0.3 and 0.3 in 978: Y plots as a U shape, and its rising right half and falling left half cancel (for every day at +x there is roughly a mirror day at −x with the same Y, and their products have opposite signs). A correlation near 0 means no straight-line link, not no link.

Short samples. For two simulated series with nothing between them (a true correlation of 0), 190 of 1,000 samples of 20 days measured a correlation of 0.3 or more either way, and the middle 950 ran from −0.45 to 0.44. Of 1,000 samples of 250 days, 0 did, and the middle 950 ran from −0.13 to 0.12.

Calm and wild spells. A measured correlation belongs to its sample's mix of calm and wild days. If the link is stronger in wild spells than in calm ones, the one number hides it, and a 50/50 mix is riskier in those spells than the formula says. The lesson's simulated pairs keep one correlation throughout, so they can't show this.

Cause. Two simulated assets each moved by a shared "market" move plus a move of their own, all three separate bell-curve draws of one size; neither saw the other's move. Across 1,000 samples of 250 days they measured 0.50 on average, and 999 measured 0.3 or more. With the market move taken out of both, they averaged 0.00, and 0 measured 0.3 or more either way. A correlation can't tell X moving Y from Y moving X, or from a third series, a confounder, moving both.

Formula: covariance and correlation

The covariance is the average product of two series' distances from their averages, dividing by n − 1; the correlation is the covariance divided by both sample standard deviations, and measures a straight-line link only.

cov = [(x1 − μx)(y1 − μy) + … + (xn − μx)(yn − μy)] ÷ (n − 1)
ρ = cov ÷ (sx × sy)
x1 … xn, y1 … yn
the paired numbers, one pair a day; n is how many pairs
μx, μy
"mu", the average: their averages
sx, sy
their sample standard deviations: how far each typically lands from its average, dividing by n − 1
ρ
"rho", the correlation, from −1 to +1
Worked example: three days

X returned +1%, +2% and +3%; Y returned +2%, 0% and +4%. Both average 2%. Distances: X −1, 0, +1; Y 0, −2, +2. Products: 0, 0, +2, so cov = 2 ÷ 2 = 1. sx = √(2 ÷ 2) = 1 and sy = √(8 ÷ 2) = 2, so ρ = 1 ÷ (1 × 2) = 0.5.

Holds whenBreaks when

The link is curved. One extreme day moves it a lot, because its distances are multiplied (real returns often have more extreme days than a bell curve; the Fat tails lesson covers this). If the link is stronger in wild spells than in calm ones, one number for the whole sample hides it.

Formula: the volatility of a 50/50 mix

The volatility of a mix holding half of each of two assets, if their correlation is the same throughout:

σmix = √(¼σ1² + ¼σ2² + ½ρσ1σ2)
σ1, σ2
the two assets' volatilities: the standard deviations of their returns
ρ
the correlation of their returns
σmix
the volatility of the mix
Worked example: two 10% assets

√(25 + 25 + 50ρ): at ρ = 1, √100 = 10%; at 0.5, √75 ≈ 8.66%; at 0, √50 ≈ 7.07%; at −0.5, √25 = 5%; at −1, √0 = 0%. With 6% and 8% at a correlation of 0.5: 9 + 16 + 12 = 37, and √37 ≈ 6.08%.

Holds whenBreaks when

If the correlation is higher in wild spells than the number put in, the mix is riskier than the formula says, and the gain from mixing shrinks when prices move most.

One more worked example

Made-up numbers

Two assets, each with a yearly volatility of 8%, and a correlation of −0.5: they tend to move opposite ways. A 50/50 mix: ¼ × 64 + ¼ × 64 + ½ × (−0.5) × 8 × 8 = 16 + 16 − 16 = 16, and √16 = 4%. The mix's volatility is half of either asset's, if the correlation stays at −0.5. At a correlation of 1 it would be √64 = 8%, and at 0, √32 ≈ 5.66%.

Common mistakes

Check yourself

  1. Over four days X returned +1%, +2%, +4% and +5%, and Y returned +2%, +1%, +5% and +4%. What is their correlation?
    Answer

    Both average 3%. Distances: X −2, −1, +1, +2; Y −1, −2, +2, +1. Products: 2, 2, 2, 2, which add up to 8, so cov = 8 ÷ 3 ≈ 2.67. Squares: X 4, 1, 1, 4 and Y 1, 4, 4, 1, both adding up to 10, so sx = sy = √(10 ÷ 3) ≈ 1.83, and their product is 10 ÷ 3 ≈ 3.33. ρ = 2.67 ÷ 3.33 = 0.8 (exactly 8 ÷ 10).

  2. Two assets have volatilities of 3% and 5% and a correlation of −1. What is the volatility of a 50/50 mix?
    Answer

    ¼ × 9 + ¼ × 25 + ½ × (−1) × 3 × 5 = 2.25 + 6.25 − 7.5 = 1, and √1 = 1%: half the gap between the two, if the correlation stays at −1.

  3. A series' daily value is fully set by a market's move, yet the two measure a correlation of 0.02 over 250 days. Can that be?
    Answer

    Yes, if the link is curved: the lesson's series Y, which rose on days X moved far either way, averaged a correlation of 0.00 across 1,000 simulated samples. Correlation measures a straight-line link only.

  4. Two series measured a correlation of 0.35 over 20 days. What does the lesson's simulation say about that?
    Answer

    In its simulation, 1,000 samples of 20 days of two series with nothing between them landed from −0.45 to 0.44 in 950 cases, so 0.35 is inside what luck gives such series. A real link would also need a reason, since a shared driver can produce one.

  5. Two assets each have a volatility of 20% and a correlation of 0.9. What is the volatility of a 50/50 mix, and what does it say about mixing them?
    Answer

    ¼ × 400 + ¼ × 400 + ½ × 0.9 × 20 × 20 = 100 + 100 + 180 = 380, and √380 ≈ 19.49%: barely below 20%. With a correlation near 1, mixing lowers risk very little, if the correlation stays at 0.9.

Try it yourself

Run the script. Every simulated number in this lesson comes from one Python script (below), which uses its own seeded draws, not the course's shared simulated market. It builds the pairs, mixes the two assets half and half, and measures and counts every correlation. Change the length of a sample, the size of the shared move, or the correlation of the two assets, and see what moves.

By hand, in a spreadsheet. Put one series in column A and the other in column B, one day a row. =CORREL(A:A,B:B) gives the correlation and =COVARIANCE.S(A:A,B:B) the covariance, dividing by n − 1. For the volatility of a 50/50 mix, with the two volatilities in D1 and D2 and the correlation in D3: =SQRT((D1^2+D2^2)/4+D3*D1*D2/2).

The code behind every number (Python, numpy; seed 2026111002)
Loading…

Honest notes

Where this comes from