Skip to main content
AI Fin Hub

Calculator

Efficient Frontier Calculator

Plot the Markowitz efficient frontier with minimum-variance and tangency (max-Sharpe) portfolios and per-asset weights. Closed-form, free, in your browser.

Runs in your browser. Nothing you enter is uploaded, and no account or API key is needed.

Education, not investment advice. Past performance does not predict future results. How we check our numbers.

Upload a multi-asset returns CSV

Wide format: date,asset_1,asset_2,…. Each column is a series of simple periodic returns as decimals. Minimum 60 observations and 2 assets; maximum 20 assets. Computation is entirely client-side.

Risk-free rate, yearly

Used for Sharpe ratios and the tangency portfolio.

Annualizes means and covariances.

Max-Sharpe portfolio

-2.12

Annualized Sharpe of the tangency portfolio: -4.8% expected return at 4.1% volatility, gross exposure 201% (weights can be negative). In-sample estimate: historical means make this optimistic out of sample.

The risk-free rate is at or above the minimum-variance portfolio's return, so no portfolio on the efficient branch beats cash; the closed-form "tangency" weights shown are not a max-Sharpe portfolio.

4 assets · 504 observations (~2.0 yrs) · rf = 4.0% · min-var vol 1.5%

Efficient frontier (shorting allowed)

equitybondscommoditiescryptoVolatility (annualized)Expected return (annualized)

Solid curve: efficient frontier (upper branch). Dashed curve: the inefficient lower branch. Hollow dot: tangency (max-Sharpe) portfolio. Amber dot: minimum-variance portfolio. Gray dots: individual assets.

Key portfolios

Tangency (max Sharpe)

Return

-4.8%

Vol

4.1%

Sharpe

-2.12

AssetWeight
equity-12.5%
bonds150.6%
commodities-33.4%
crypto-4.7%

Minimum variance

Return

2.9%

Vol

1.5%

Sharpe

-0.76

AssetWeight
equity19.5%
bonds74.5%
commodities5.9%
crypto0.1%

Formulas

min-var:   w* = Σ⁻¹·1 / (1ᵀ·Σ⁻¹·1)
tangency:  w* = Σ⁻¹·(μ − rf·1) / (1ᵀ·Σ⁻¹·(μ − rf·1))
frontier:  w(μ_t) = λ·Σ⁻¹·μ + γ·Σ⁻¹·1
  λ = (C·μ_t − A) / D,  γ = (B − A·μ_t) / D
  A = μᵀΣ⁻¹1, B = μᵀΣ⁻¹μ, C = 1ᵀΣ⁻¹1, D = B·C − A²

Shorting is allowed and there are no position limits: these are the unconstrained closed-form solutions. Long-only or capped weights (w ≥ 0, w ≤ cap) need a quadratic-program solver, which this tool does not include.

How to use it

  1. Upload a wide-format CSV of simple returns (an optional date column, then one column per asset, at least 60 rows and 2 to 20 assets), or load the four-asset demo.
  2. Set the yearly risk-free rate and the return frequency (daily, weekly or monthly) so means and covariances are annualized correctly.
  3. Read the tangency portfolio's Sharpe ratio, return, volatility and gross exposure, and check the chart: the solid curve is the efficient frontier, the hollow dot the tangency portfolio, the amber dot the minimum-variance portfolio.
  4. Read the weights of both portfolios. Weights can be negative because shorting is allowed and there are no position limits.
  5. Re-run on a different date range or frequency. Weights that swing a lot between samples mean the estimates are too noisy to use as is.

Questions people ask

How is the frontier constructed?

With Markowitz's (1952) mean-variance model solved in closed form. The tool estimates annualized means and the covariance matrix from your return series, then uses the two-fund theorem: the minimum-variance portfolio is Σ⁻¹1 / (1ᵀΣ⁻¹1), the tangency portfolio is Σ⁻¹(μ − rf) normalized to sum to 1, and every frontier point is a combination of Σ⁻¹μ and Σ⁻¹1. Sweeping the target return traces the frontier; the upper branch is the efficient set.

Why do the inputs need so many observations?

Covariance estimation is data-hungry: 10 assets have 55 variances and covariances to estimate, so 60 monthly observations leave very few degrees of freedom. The tool requires 60 rows per asset and at most 20 assets, but it does not warn beyond that or shrink the matrix. Aim for many more observations than assets (ten times is a common rule of thumb), and treat weights from short samples as unstable.

Does the tool support constraints?

No. It computes the unconstrained closed-form solution, so weights can be negative (short positions) and there are no caps or minimum positions; weights always sum to 100%. Long-only or capped portfolios need a quadratic-program solver. Constraints shrink the feasible set, so a constrained frontier lies at or below this one at every volatility.

What's wrong with mean-variance optimization?

Two well-known issues: small changes in the expected-return estimates swing the weights a lot, and variance treats upside and downside alike, ignoring skew and fat tails. The tool has no alternative objective such as CVaR; for robust allocations look at shrinkage estimators, Black-Litterman, or risk parity, and read in-sample max-Sharpe weights as an upper bound on what is achievable.

How are expected returns estimated?

From the historical mean of each series, compounded to a year: (1 + mean periodic return)^periods − 1, with periods set by the return frequency you choose. There is no way to enter your own expected-return vector. Historical means are a noisy estimate of future returns, which is the main reason in-sample tangency weights rarely survive out of sample.

  • Calculators Portfolio Correlation Matrix

    Paste a multi-asset returns CSV. See the Pearson correlation heatmap, condition number, average absolute correlation, and eigenvalue concentration.

  • Calculators Risk-Adjusted Returns Calculator

    Paste a returns CSV. Sharpe, Sortino, Calmar, Omega, alpha, beta, tracking error, information ratio, max drawdown, and tail moments — plus.

  • Calculators Kelly Criterion Calculator

    Size positions with full, half, quarter, or eighth Kelly and stress-test the choice with a drawdown Monte Carlo simulator. Client-side. Private by default.

All articles

Use it from code

The same calculation as a JavaScript module you can import. It runs where you import it, with no request, key or rate limit.

import { compute } from "https://aifinhub.io/engines/efficient-frontier-builder.js";

Input and output contract and the guide for agents.