Efficient Frontier Calculator

Short sales
Assets (returns and volatilities in % a year)
#NameExpected returnVolatility
1
2

Correlations (between −1 and 1, one box for each pair below the diagonal; the shaded boxes fill themselves and a blank box is 0. A matrix copied from a spreadsheet can be pasted into any box.)

12
1 1
2 1
Estimate from a table of returns

Paste periodic returns in %, one row per period and one column per asset, as copied from a spreadsheet. A first row of names is used as the asset names. The boxes above are filled with the annualized means, volatilities and correlations.

How to use it

  1. Choose whether short sales (negative weights) are allowed.
  2. Choose the number of assets and enter each one’s expected return and volatility, in percent a year.
  3. Enter the correlation between each pair of assets in the lower triangle of the matrix. A blank box is taken as 0.
  4. Enter the risk-free rate. To see the portfolio that earns a particular return with the least risk, enter it as the target return.
  5. The minimum-variance and tangency portfolios, the chart of the frontier and the working appear and update as you type.

To estimate the inputs from history instead, open “Estimate from a table of returns”. To see it filled in, choose “Show an example”. The answers are only as good as the expected returns entered, and small changes in them can move the weights a long way. For study and comparison; not financial advice.

Result

Enter asset 1’s expected return.

Returns and volatilities are per year. Weights add up to 100 %; a negative weight is a short sale. The Sharpe ratio is the excess return over the risk-free rate per unit of volatility.

Methodology, equations and examples

The efficient frontier is the set of portfolios that earn the highest expected return for each level of risk. Harry Markowitz introduced it in 1952. Risk is measured by volatility, the standard deviation of the portfolio's return. A portfolio below the frontier is inefficient: some other mix of the same assets earns more for the same volatility, or carries less volatility for the same return.

Inputs

  • μᵢ – Expected return of asset i, per year
  • σᵢ – Volatility of asset i, per year
  • ρᵢⱼ – Correlation between the returns of assets i and j
  • r_f – Risk-free rate, per year
  • w – Portfolio weights, which add up to 1. A negative weight is a short sale.

The covariance matrix Σ collects the risk of every pair of assets: Σᵢⱼ = ρᵢⱼ σᵢ σⱼ, with σᵢ² on the diagonal. A portfolio's expected return is wᵀμ and its variance is wᵀΣw. The correlations must be consistent with each other, which means Σ must be positive definite. The calculator checks this with a Cholesky factorization and says so when it fails. Two assets with a correlation of exactly 1 or −1 also fail, because one can then be built from the other and the matrix has no inverse.

With short sales: the closed form

When weights may be negative, the frontier has an exact solution (Merton, 1972). Four constants come from the inverse of the covariance matrix:

A = 1ᵀΣ⁻¹1, B = 1ᵀΣ⁻¹μ, C = μᵀΣ⁻¹μ, D = AC − B²

  • The global minimum-variance portfolio is w = Σ⁻¹1 / A. Its return is B / A and its variance is 1 / A.
  • The portfolio with the least variance for a target return m is w = [(C − Bm) Σ⁻¹1 + (Am − B) Σ⁻¹μ] / D. Its variance is σ² = (Am² − 2Bm + C) / D. Plotted as volatility against return this is a hyperbola: the frontier. Its upper half, above the minimum-variance portfolio, is the efficient frontier.
  • The tangency portfolio is w = Σ⁻¹(μ − r_f 1) / (B − A r_f). It has the highest Sharpe ratio, (return − r_f) / volatility, of any portfolio, √(C − 2 r_f B + r_f² A). It exists on the efficient frontier only when r_f is below the minimum-variance return B / A.

The calculator solves Σx = 1 and Σx = μ by Gaussian elimination rather than forming Σ⁻¹ itself.

Without short sales

With every weight held at zero or above, there is no closed form, and most software uses an iterative quadratic programming method. This calculator uses an exact search instead. The best long-only portfolio holds some subset of the assets, and on that subset it is the closed-form answer above with every weight positive. With at most 10 assets there are at most 1,023 subsets, so the calculator works out the closed-form portfolio on each, discards those with a negative weight, and keeps the one with the least variance (or, for the tangency portfolio, the highest Sharpe ratio). The long-only frontier ends at the lowest and highest expected returns, since no mix of assets held long can earn more than the best of them.

The capital market line

Combining the tangency portfolio with lending or borrowing at the risk-free rate gives the capital market line, return = r_f + Sharpe × volatility. Every point on it beats the frontier, except the tangency point where the two touch. This is the two-fund separation result: every investor who uses these inputs holds the same risky portfolio and differs only in how much of it they hold.

Estimating the inputs from history

"Estimate from a table of returns" computes the inputs from periodic returns. The expected return is the mean periodic return times the number of periods a year. The volatility is the sample standard deviation (dividing by n − 1) times the square root of the number of periods a year. Correlations are the sample correlations. Historical means are a poor guide to future returns: a mean estimated from 5 years of monthly data has a standard error of roughly σ / √5, often as large as the mean itself. The weights are very sensitive to the expected returns, so treat estimated inputs as a starting point.

Example

A bond fund D has an expected return of 8 % and a volatility of 12 %. A stock fund E has 13 % and 20 %. Their correlation is 0.3 and the risk-free rate is 5 %. This is the two-fund example in Bodie, Kane and Marcus, Investments, chapter 7.

The covariance is 0.3 × 0.12 × 0.20 = 0.0072. With two assets the minimum-variance weight of D has its own closed form:

w_D = (σ_E² − Cov) / (σ_D² + σ_E² − 2 Cov) = (0.04 − 0.0072) / (0.0144 + 0.04 − 0.0144) = 0.82

So the minimum-variance portfolio is 82 % D and 18 % E. Its return is 0.82 × 8 % + 0.18 × 13 % = 8.9 %, and its volatility is √(0.82² × 0.0144 + 0.18² × 0.04 + 2 × 0.82 × 0.18 × 0.0072) = 11.45 %.

The tangency weight of D is

w_D = [(8 % − 5 %) × 0.04 − (13 % − 5 %) × 0.0072] / [(8 % − 5 %) × 0.04 + (13 % − 5 %) × 0.0144 − (3 % + 8 %) × 0.0072] = 0.000624 / 0.00156 = 0.40

The tangency portfolio is 40 % D and 60 % E. It returns 11 % at a volatility of 14.2 %, a Sharpe ratio of (11 % − 5 %) / 14.2 % = 0.42. Both weights are positive, so the answer is the same with or without short sales.

Top