Stock Correlation & Portfolio Volatility Calculator

Paste two aligned columns of historical returns. Compare full-sample correlation with rolling windows, review the sample volatility at your entered allocation and find the weight with the lowest variance within this sample.

Historical returns worksheet

Compare stock correlation and portfolio volatility

The entered mix has more volatility than the historical minimum.
Edit paired returns and portfolio parameters

Enter both assets for the same period on each line, oldest first. Use percent values, so 2.5 represents a 2.5% return.

Stock return correlation

-0.380608

8 matched periods. Covariance -2.428571 percentage points squared.

Entered mix

1.437197% sample SD

55% in A · -0.0875% mean per period.

Historical minimum

1.404776% sample SD

47.773279% in A · -0.1417% mean per period.

Volatility across allocation weights

The circle marks the entered weight. The gold diamond marks the sample minimum when it has one weight.

Sample portfolio standard deviation by Asset A percentageAt 55% Asset A, sample standard deviation is 1.437197 percent. The minimum is 1.404776 percent at 47.773279% Asset A.0%100%Weight in Asset A

Vertical scale 0% to 2.60494% sample SD.

Rolling return correlation

Each point uses the last 4 paired returns. Gaps indicate a constant asset within that window.

Pearson return correlation by rolling ending periodPeriod 4: 0.974913. Period 5: 0.128388. Period 6: -0.385164. Period 7: -0.959448. Period 8: -0.989681.+10−148Window ending period

Periods 5–8 · -0.989681

Review paired returns and export exact CSV
Paired period returns at the entered portfolio weight
PeriodAsset AAsset BEntered mix
11%0%0.55%
2-2%-3%-2.45%
33%2%2.55%
4-1%-1%-1%
54%-4%0.4%
6-2%1%-0.65%
72%-2%0.2%
8-3%3%-0.3%

The worksheet describes the entered sample and holds the weights constant each period. Results vary with the period and returns you select.

How to use this calculator

  1. Paste matched periodic returns in order, one pair per line. Use returns for the same periods and the same return definition.
  2. Enter the fraction of the mix invested in Asset A, as a percent. Asset B takes the rest.
  3. Set the number of periods in each rolling window and inspect a window.
  4. Compare the entered allocation with the lowest sample variance across long-only weights.
  5. Download exact covariance, variance, rolling components and period return contributions.

The Formula

The mathematical logic powering this calculation is:

Enter aligned simple historical returns for Asset A and Asset B, with the oldest matched period first. Each value is a percentage. The worksheet describes the submitted sampling frequency. A number like 2.5 means a 2.5% return.

Compute each series's sample mean, sample variance and the sample covariance, dividing sums of centered squares or products by n − 1. Pearson correlation is covariance divided by the two sample standard deviations. A series with zero variation makes correlation undefined. Recompute the same quantities on each consecutive window for rolling correlation.

At long-only weight w in Asset A, the entered portfolio return is w × A + (1 − w) × B for each period. Its sample variance is w² Var(A) + (1 − w)² Var(B) + 2w(1 − w) Cov(A,B). Portfolio standard deviation is the square root. The worksheet assumes a constant starting weight each period. It excludes transaction costs and models the supplied simple returns over one consistent interval.

Let D = Var(A) + Var(B) − 2 Cov(A,B), which equals the sample variance of A minus B. If D is positive, the unconstrained minimum occurs at w = (Var(B) − Cov(A,B))/D. The long-only sample minimum clips that result to the interval from 0 to 1. If D is zero, variance is the same at every allocation. Sample means and variances are exact rational numbers. Displayed standard deviations and correlations approximate square roots. The CSV carries exact variance, covariance and signed squared correlation components.

Enter 3–48 aligned rows, returns from −100% through 1,000%, and a weight between 0 and 100%. Use up to six fractional places. Rolling windows range from two observations through the smaller of 24 periods and the available row count. These are historical measurements from your selected sample. A reported minimum can change when the dates, return data or constraints change.

Worked Example

If you input:

  • Paired returns: Eight matched periods
  • Weight: 55% in A
  • Window: Four periods

Result:

Full-sample correlation is about −0.380608. The entered 55% mix has a sample standard deviation of about 1.437197%. The minimum in this sample occurs near 47.773279% Asset A.

Frequently Asked Questions

Can I paste stock prices instead of returns?

Enter matched simple percentage returns. For prices, calculate each period's return using a consistent approach to splits and distributions before pasting.

Does correlation alone determine portfolio volatility?

The asset variances, weight split and covariance all matter. The same correlation can correspond to different portfolio standard deviations when the asset volatilities change.

What makes rolling correlation undefined?

At least one asset is constant in that window. The covariance and both variances can still be recorded.

Can the lowest sample variance be zero?

Yes. For example, exact opposing return changes can cancel at a particular allocation. That observation applies to the supplied returns.

What if every allocation gives the same variance?

That occurs when the period-by-period difference between the two series is constant. Every weight then gives the same sample volatility, although the sample means can differ.

Are the displayed risks annualized?

They apply to the interval of the returns you enter, such as a week or month. The tool keeps that interval for both the mean and standard deviation.

Similar Calculators