aifinhub

Methodology · Calculator · Last updated 2026-04-20

How Efficient Frontier Builder works

How the Efficient Frontier Builder tool actually works — Markowitz derivation, assumptions, limitations.

Scope

Closed-form Markowitz mean-variance optimisation. Given an asset universe's return history, the tool computes the efficient frontier (set of portfolios with the maximum expected return for each level of variance), the minimum-variance portfolio, and the tangency (max-Sharpe) portfolio.

Shorting is implicitly allowed — weights can be negative. Long-only optimisation requires a quadratic programming solver and is on the roadmap; it is not implemented in this release.

Inputs

date,asset_1,asset_2,asset_3,asset_4
2024-01-02,0.0012,0.0008,-0.0003,0.0015
2024-01-03,-0.0005,-0.0002,0.0004,-0.0006
...

Wide-format CSV with a date column (optional) and 2–20 numeric asset-return columns. Minimum 60 observations. Returns are treated as simple daily returns; annualisation uses 252 trading days.

Closed-form solutions

Let μ be the vector of annualised expected returns, Σ the annualised covariance matrix, 1 a vector of ones, and rf the annualised risk-free rate.

Minimum-variance portfolio

The unique portfolio with the lowest variance subject to weights summing to one:

w*_min = Σ⁻¹ · 1 / (1ᵀ · Σ⁻¹ · 1)

Tangency (max-Sharpe) portfolio

The portfolio that maximises the Sharpe ratio over the risk-free rate:

w*_tan = Σ⁻¹ · (μ − rf·1) / (1ᵀ · Σ⁻¹ · (μ − rf·1))

Frontier (two-fund theorem)

For any target return μ_t, the minimum-variance portfolio with that expected return is:

w(μ_t) = λ · Σ⁻¹ · μ + γ · Σ⁻¹ · 1
λ = (C · μ_t − A) / D
γ = (B − A · μ_t) / D
A = μᵀ Σ⁻¹ 1,  B = μᵀ Σ⁻¹ μ,  C = 1ᵀ Σ⁻¹ 1,  D = B · C − A²

The tool sweeps μ_t across a range centred on the minimum-variance return, producing 60 frontier points.

Numerical details

  • Covariance uses the sample estimator (divide by n − 1).
  • Matrix inversion: Gauss-Jordan elimination with partial pivoting. Matrices up to 20×20 — accuracy is not a concern.
  • If the covariance matrix is singular (e.g. two columns are perfectly correlated), the tool raises a diagnostic error rather than returning noise.
  • Annualisation: μ_ann = (1 + μ_daily)^252 − 1, Σ_ann = Σ_daily × 252.

Assumptions + limitations

  1. Shorting allowed. Weights are unconstrained in sign. A long-only frontier is strictly inside this one; real-world retail investors typically want long-only.
  2. Sample moments are true moments. Markowitz takes the sample mean and covariance at face value. Sample-mean estimation error is notoriously large; tiny shifts in μ produce wildly different tangency portfolios. For production, shrink μ toward a factor prior (Black-Litterman, James-Stein) and apply covariance shrinkage.
  3. Gaussian-in-spirit. Mean-variance is the correct objective if returns are normal and investor utility is quadratic. Under fat-tailed returns, minimising variance may not minimise risk; consider CVaR-based optimisation for tail-aware allocation.
  4. Static covariance. The covariance structure is assumed stationary. Crises change correlation structure dramatically; diversification benefits collapse precisely when needed.
  5. No transaction costs. The frontier presents in-sample, cost-free portfolios. Rebalancing frictions materially alter achievable outcomes; model them separately.
  6. No turnover or concentration constraints. Mean-variance optima frequently concentrate in two or three assets. Add weight caps in practice.

Privacy

Parsing, inversion, and frontier construction all run in the browser. Nothing is uploaded.

References

  • Markowitz, H. (1952). "Portfolio Selection." Journal of Finance 7(1), 77–91.
  • Merton, R. C. (1972). "An Analytic Derivation of the Efficient Portfolio Frontier." JFQA 7(4).
  • Black, F., & Litterman, R. (1992). "Global Portfolio Optimization." Financial Analysts Journal 48(5).
  • Ledoit, O., & Wolf, M. (2004). "A Well-Conditioned Estimator for Large-Dimensional Covariance Matrices." JMVA 88(2).
  • Michaud, R. O. (1989). "The Markowitz Optimization Enigma: Is Optimized Optimal?" Financial Analysts Journal 45(1).

Connects to

Changelog

  • 2026-04-20 — Initial release: closed-form frontier + min-var + tangency, shorting allowed.
Planning estimates only — not financial, tax, or investment advice.