Portfolio optimizer
Pick 2 to 8 ETFs, a period and a minimum and maximum weight for each, and the optimizer calculates four portfolios on their real monthly returns: maximum Sharpe ratio, minimum volatility, risk parity and equal weight, with the efficient frontier and a test on months the optimiser did not see. It runs in your browser and gives the same result every time.
Data updated November 13, 2026
Short answer. A portfolio optimizer calculates the weights that would have best met an objective, such as the highest Sharpe ratio or the lowest volatility, on past returns. For SPY, EFA, AGG, TLT and GLD, optimised on Jun 2007 to Jan 2017, the maximum Sharpe mix was 89% AGG, 9.7% SPY and 1% GLD, with a Sharpe ratio of 0.92 in those months; held from Feb 2017 to Oct 2026, the same weights had 0.14. The minimum volatility mix (96% AGG and 4% SPY) had a volatility of 3.9%, then 5.3%. Equal weights, which need no estimates, had a Sharpe ratio of 0.59 in the second half.
- Max Sharpe: Sharpe in-sample
- 0.92
- Max Sharpe: Sharpe out-of-sample
- 0.14
- Min volatility: in / out of sample
- 3.9% / 5.3%
- Equal weight: Sharpe out-of-sample
- 0.59
Monthly total returns with dividends reinvested, rebalanced monthly, no costs; Sharpe ratios on excess returns over 1–3 month US Treasury bills (BIL). Common history Jun 2007 to Oct 2026 (233 months, prices to November 13, 2026), split in two halves. Historical data, not a recommendation.
Efficient frontier , Jun 2007 to Oct 2026 (233 months)
Average annual return is the arithmetic mean of monthly returns × 12, the input mean-variance optimisation uses. The compound return a year (CAGR) below is lower, because volatility drags compounding.
Maximum Sharpe ratio
- Return a year
- +10.0%
- Volatility
- 11.2%
- Sharpe
- 0.77
- Max drawdown
- −25.9%
| Fund | Weight | Risk | |
|---|---|---|---|
| SPY | 55% | 62% | |
| GLD | 35% | 35% | |
| TLT | 9.7% | 2.5% | |
| EFA | 0% | 0% | |
| AGG | 0% | 0% |
Minimum volatility
- Return a year
- +3.0%
- Volatility
- 4.6%
- Sharpe
- 0.31
- Max drawdown
- −16.7%
| Fund | Weight | Risk | |
|---|---|---|---|
| AGG | 99% | 99% | |
| SPY | 1.2% | 1.2% | |
| EFA | 0% | 0% | |
| TLT | 0% | 0% | |
| GLD | 0% | 0% |
Risk parity (equal risk contribution)
- Return a year
- +5.7%
- Volatility
- 7.6%
- Sharpe
- 0.56
- Max drawdown
- −19.6%
| Fund | Weight | Risk | |
|---|---|---|---|
| AGG | 39% | 20% | |
| TLT | 18% | 20% | |
| SPY | 15% | 20% | |
| GLD | 15% | 20% | |
| EFA | 12% | 20% |
Equal weight
- Return a year
- +6.6%
- Volatility
- 9.0%
- Sharpe
- 0.58
- Max drawdown
- −21.1%
| Fund | Weight | Risk | |
|---|---|---|---|
| SPY | 20% | 25% | |
| EFA | 20% | 30% | |
| AGG | 20% | 7.4% | |
| TLT | 20% | 14% | |
| GLD | 20% | 24% |
Risk: each fund’s share of the portfolio’s variance. A negative share means the fund lowered total risk.
Out-of-sample check: optimise on the first half, test on the second
Each method chose its weights using only Jun 2007 to Jan 2017; the same weights were then held, rebalanced monthly, from Feb 2017 to Oct 2026.
| Method (weights from the first half) | Sharpe, first half | Sharpe, second half | Return a year | Volatility | Max drawdown |
|---|---|---|---|---|---|
| Max Sharpe89% AGG, 9.7% SPY, 1.0% GLD | 0.92 | 0.14 | +3.1% | 5.5% | −15.8% |
| Min volatility96% AGG, 4.0% SPY | 0.90 | −0.02 | +2.2% | 5.3% | −16.2% |
| Risk parity43% AGG, 19% TLT, 16% SPY, 12% GLD, 11% EFA | 0.70 | 0.42 | +5.5% | 7.9% | −19.7% |
| Equal weight20% SPY, 20% EFA, 20% AGG, 20% TLT, 20% GLD | 0.56 | 0.59 | +7.7% | 9.3% | −21.1% |
Return, volatility and drawdown are for the second half. Equal weight needs no estimate, so it is the same mix in both halves.
Monthly total returns with dividends reinvested, complete months only, rebalanced every month, no costs or taxes. Sharpe ratios use excess returns over 1–3 month US Treasury bills (BIL) , which averaged +1.7% a year over the period. Maximum Sharpe here: 0.77. Historical data, not a forecast.
What a portfolio optimizer does
A portfolio optimizer turns three kinds of estimate into weights: the return you expect from each asset, how much each one swings, and how they move together. Given an objective, such as the highest return per unit of risk, and limits on the weights, it searches every possible mix and returns the one that scores best.
Here the estimates come from history: the average monthly excess returns of the funds you pick and their covariance matrix, over the period you choose. The optimizer then answers a precise question: which fixed mix, rebalanced every month, would have scored best on that objective over those months? It cannot answer which mix will do best next, and the gap between the two questions is the subject of the over-fitting section below.
Mean-variance optimisation and the efficient frontier
Harry Markowitz set out the method in “Portfolio Selection” (Journal of Finance, 1952), work that earned him a share of the 1990 Nobel Memorial Prize in Economic Sciences. It describes a portfolio by two numbers, its expected return and its variance, and looks for the mixes that cannot be improved on one without giving up on the other:
minimise w′Σw (portfolio variance)
subject to w′μ = target return
w₁ + w₂ + … + wₙ = 1
minᵢ ≤ wᵢ ≤ maxᵢ (your limits)
w = weights, μ = expected excess returns, Σ = covariance matrixSolving it for every target return between the lowest-risk mix and the highest-return mix traces the efficient frontier, the blue line on the chart. Each light dot below it is a mix that was beaten on both counts by a point on the line. The frontier bends to the left of the single funds because volatility does not add up: when two funds are not perfectly correlated, part of their swings cancel out. That bend is diversification measured.
Maximum Sharpe ratio portfolio
maximise (w′μ − Rf) / √(w′Σw) with the same limits
The maximum Sharpe portfolio is the efficient mix with the most excess return per unit of volatility: the point where a straight line from the risk-free rate just touches the frontier (the dashed line on the chart). In the textbook version, with unlimited borrowing and lending at the risk-free rate, every investor would hold this one mix and adjust risk by adding cash or leverage. It is also the portfolio that depends most on the expected returns, the input with the largest estimation error, so it is the least stable of the four. The Sharpe ratio calculator explains the ratio itself and shows it for popular ETFs.
Minimum volatility portfolio
minimise w′Σw with the weights summing to 1 and your limits
The minimum volatility portfolio ignores expected returns altogether. It needs only volatilities and correlations, which are estimated far more precisely than averages, so its weights change less from one period to the next. The cost is that it can end up with a low return and a heavy concentration in the calmest asset (here 99% AGG and 1.2% SPY). A maximum weight per fund is the usual fix.
Risk parity (equal risk contribution)
risk contribution of fund i: RCᵢ = wᵢ · (Σw)ᵢ / (w′Σw) risk parity: RC₁ = RC₂ = … = RCₙ = 1/n
Equal weight splits the money evenly; risk parity splits the risk evenly. A fund’s risk contribution is its weight times its covariance with the whole portfolio, and the contributions add up to 100% of the variance. With five funds each contributes 20%, so a fund that is twice as volatile gets roughly half the weight. When all correlations are equal this reduces to weighting by inverse volatility; with real correlations it does not, and the optimizer solves the full problem. The properties of this portfolio were set out by Maillard, Roncalli and Teïletche (“The Properties of Equally Weighted Risk Contribution Portfolios”, Journal of Portfolio Management, 2010); the idea is behind allocations such as the All Weather portfolio. More in the risk parity glossary entry.
Equal weight (1/N)
The simplest allocation, and a demanding benchmark. DeMiguel, Garlappi and Uppal (“Optimal Versus Naive Diversification”, Review of Financial Studies, 2009) tested 14 optimisation models on seven datasets and found that none was consistently better than 1/N out of sample on Sharpe ratio, certainty-equivalent return or turnover. The tool shows it next to the optimised portfolios so you can make the same comparison on your funds.
Constraints: minimum and maximum weights, long-only
Every fund has a minimum and a maximum weight, 0% and 100% by default, and the weights always add up to 100%. A maximum stops the optimiser from putting most of the money in one fund; a minimum keeps a fund in the mix whatever its past numbers. If the minimums add up to more than 100%, or the maximums to less, no portfolio can satisfy them and the tool says so.
Long-only is the default: no weight can be negative. Untick it to allow short positions down to −50% per fund; the optimiser then can hold more than 100% in the other funds, and borrowing costs are ignored. Jagannathan and Ma (“Risk Reduction in Large Portfolios: Why Imposing the Wrong Constraints Helps”, Journal of Finance, 2003) showed that the no-short-sale limit acts like shrinking the most extreme covariance estimates, which is why constrained minimum-variance portfolios often do as well out of sample as ones built with more elaborate estimators.
Risk parity needs positive weights, so it stays long-only; when your limits make equal risk contributions impossible, the tool returns the mix within the limits whose contributions are closest to equal, and says so on its card.
Worked example: optimising SPY, EFA, AGG, TLT and GLD
The calculation the optimizer runs when the page opens, on the full common history of the default funds (Jun 2007 to Oct 2026, 233 months), with weights between 0% and 100%.
- Estimate the inputs from the monthly total returns in excess of T-bills. Annualised average return (before subtracting T-bills) and volatility of each fund: SPY 11.3% and 15.5%, EFA 5.8% and 17.4%, AGG 3.0% and 4.7%, TLT 3.8% and 14.2% and GLD 10.3% and 17.6%. With 5 funds the covariance matrix has 5 variances and 10 covariances.
- Minimum volatility: minimise the portfolio variance w′Σw with the weights summing to 100%. Result: 99% AGG and 1.2% SPY. It returned 3.0% a year with a volatility of 4.6%, a Sharpe ratio of 0.31 and a deepest fall of −16.7%. That is about as calm as AGG on its own (4.7%): the other funds added little diversification against it.
- Maximum Sharpe ratio: among the efficient mixes, the one with the highest average excess return per unit of volatility. Result: 55% SPY, 35% GLD and 9.7% TLT. It returned 10.0% a year with a volatility of 11.2%, a Sharpe ratio of 0.77 and a deepest fall of −25.9%.
- Risk parity: weights such that each fund contributes the same share of the portfolio’s variance (20% each). Result: 39% AGG, 18% TLT, 15% SPY, 15% GLD and 12% EFA. It returned 5.7% a year with a volatility of 7.6%, a Sharpe ratio of 0.56 and a deepest fall of −19.6%.
- Equal weight, for comparison: 20% in each fund. It returned 6.6% a year with a volatility of 9.0%, a Sharpe ratio of 0.58 and a deepest fall of −21.1%.
- The out-of-sample check repeats the first four steps on the first half of the months only and holds those weights through the second half. Its results are in the tool above and in the section on over-fitting below.
To see how any of these mixes behaved through past crises, with rebalancing choices and cash flows, open it in the portfolio backtest (each card above has a link). For two or three funds, the efficient frontier calculator plots every mix in 5% steps.
Why optimisers over-fit
An optimiser does not know which part of a fund’s past return was skill or a lasting risk premium and which was luck. It treats the whole average as a known future return, and it rewards the funds whose estimates happen to be highest with the largest weights. Richard Michaud called mean-variance optimisers “estimation-error maximizers” (“The Markowitz Optimization Enigma: Is ‘Optimized’ Optimal?”, Financial Analysts Journal, 1989), and in their tests Chopra and Ziemba (1993) found that errors in expected returns did roughly ten times as much damage to the result as errors in variances.
The cleanest test is to optimise on one stretch of history and hold the weights through a later one. For SPY, EFA, AGG, TLT and GLD, the table below does that with the first half of the data (Jun 2007 to Jan 2017) and the second half (Feb 2017 to Oct 2026).
| Method | Sharpe, Jun 2007–Jan 2017 | Sharpe, Feb 2017–Oct 2026 | Volatility, first / second half |
|---|---|---|---|
| Maximum Sharpe ratio89% AGG, 9.7% SPY and 1% GLD | 0.92 | 0.14 | 4.0% / 5.5% |
| Minimum volatility96% AGG and 4% SPY | 0.90 | −0.02 | 3.9% / 5.3% |
| Risk parity (equal risk contribution)43% AGG, 19% TLT, 16% SPY, 12% GLD and 11% EFA | 0.70 | 0.42 | 6.7% / 7.9% |
| Equal weight20% SPY, 20% EFA, 20% AGG, 20% TLT and 20% GLD | 0.56 | 0.59 | 8.8% / 9.3% |
The maximum Sharpe weights had a Sharpe ratio of 0.92 in the months they were chosen on and 0.14 afterwards, a fall of 0.78. In the second half the highest Sharpe ratio of the four came from equal weights, with 0.59. The ranking changes with the funds and the dates; run the check on your own selection rather than generalising from one example.
Ways to reduce over-fitting
- Prefer objectives that do not use average returns (minimum volatility, risk parity) when you have no view on returns.
- Cap the weight of each fund, and keep the number of funds small relative to the years of data.
- Use the longest history the funds share, and check that the weights stay similar over different sub-periods.
- Judge the result on the out-of-sample half, and against equal weights, not on the in-sample Sharpe ratio.
- Professional tools go further with shrinkage of the estimates (Ledoit and Wolf), Black-Litterman views, resampling or hierarchical risk parity; see the comparison of portfolio optimization software.
How this optimizer calculates
- Data. Monthly total returns with dividends reinvested, complete months only, on the months all chosen funds have in common. The risk-free rate is the monthly return of the BIL Treasury bill ETF (the XEON €STR ETF when every fund is listed in euros), subtracted month by month.
- Estimates. Sample averages and the sample covariance matrix of the excess returns, annualised (× 12). No shrinkage, so you see what the raw history implies.
- Minimum volatility and the frontier. Each is a quadratic programme with the weights summing to 100% and your limits, solved exactly with an active-set method. The frontier has 25 points evenly spaced in return, from the minimum volatility mix to the highest-return mix your limits allow.
- Maximum Sharpe. A search along the efficient frontier, where the tangency portfolio lies, refined with a golden-section search. The Sharpe ratio it maximises is the one reported: monthly excess returns of the mix rebalanced monthly, annualised with √12.
- Risk parity. Cyclical coordinate descent on the equal-risk-contribution problem (Griveau-Billion, Richard and Roncalli, 2013), then a projected-gradient step when your limits bind.
- Results. Each mix is replayed with monthly rebalancing and no costs: compound return, volatility, Sharpe ratio and maximum drawdown on month-end values. No random numbers are involved except a fixed-seed sample of mixes for the chart, so the same inputs always give the same output.
How to use optimiser results sensibly
Treat the weights as a description of the past, not a target. Change the period from 10 years to 5 or to the full history and watch how much the maximum Sharpe weights move: the more they move, the less the result tells you about the future.
Trust the risk side more than the return side. Volatilities and correlations are estimated far more reliably than average returns, which is why minimum volatility and risk parity usually hold up better out of sample than maximum Sharpe.
Use limits. A cap on each fund and a small minimum for funds you want to keep turn an extreme answer into a usable one, and the cost in historical Sharpe ratio is usually small: compare the results with and without them.
Compare with equal weights. If an optimised mix does not beat the equal-weight portfolio in the second half of the data, the optimisation added complexity without evidence that it adds value.
Test before deciding. Open the mix in the portfolio backtest, look at its worst years and drawdowns, and check it against your goals and horizon. The results are educational and are not investment advice.
Portfolio optimizer: questions
What is a portfolio optimizer?
A tool that calculates the weights of a set of assets that best meet an objective, such as the highest Sharpe ratio or the lowest volatility, within limits you set. It works from estimates of each asset’s return, volatility and correlations, usually taken from past data, so the result is the best mix for the past period, not a forecast.
How does mean-variance optimization work?
Harry Markowitz’s method (1952) treats a portfolio as a trade-off between expected return and variance. For each target return it finds the weights with the lowest variance, given the assets’ expected returns and their covariance matrix. The set of those portfolios is the efficient frontier; every other mix is less efficient, with more volatility for the same return or less return for the same volatility.
What is the maximum Sharpe ratio portfolio?
The mix on the efficient frontier with the highest excess return over the risk-free rate per unit of volatility. It is the point where a straight line from the risk-free rate touches the frontier, which is why it is also called the tangency portfolio. In theory any investor could hold it and adjust risk by adding cash or borrowing; in practice it is the result most sensitive to errors in the expected returns.
What is the minimum volatility portfolio?
The mix with the lowest volatility the assets allow, whatever its return. It needs only volatilities and correlations, not expected returns, which makes it more stable than the maximum Sharpe portfolio. It tends to concentrate in the least volatile asset, usually short or aggregate bonds. On SPY, EFA, AGG, TLT and GLD from Jun 2007 to Oct 2026, it was 99% AGG and 1.2% SPY, with a volatility of 4.6%.
What is risk parity, and how is it different from equal weight?
Equal weight gives each asset the same share of the money. Risk parity, or equal risk contribution, gives each the same share of the portfolio’s risk: an asset’s contribution is its weight times its covariance with the portfolio, divided by the portfolio variance. Volatile assets therefore get smaller weights and calm ones larger weights. Like minimum volatility, it does not use expected returns.
Is risk parity better than mean-variance optimization?
Neither is better in general. Risk parity is more stable because it ignores return estimates, which are the noisiest input, but it usually holds a lot of bonds and some versions use leverage to reach a target return. Mean-variance can match any return target but reacts strongly to small changes in the inputs. The out-of-sample check in the tool shows how each did on months it had not seen for the funds you pick.
Why do optimized portfolios often do worse than expected?
Because the optimizer treats past average returns as known, it puts the most weight in the assets whose past returns were luckiest, and luck does not repeat. Richard Michaud (1989) called mean-variance optimizers “estimation-error maximizers”. In the default example, the maximum Sharpe mix chosen on Jun 2007 to Jan 2017 had a Sharpe ratio of 0.92 in those months and 0.14 from Feb 2017 to Oct 2026, against 0.59 for equal weights.
Should I invest with the weights the optimizer gives?
This tool describes history; it is not a recommendation and does not know your goals, horizon, taxes or other holdings. Use the results to understand how combining the funds changed risk, which funds dominate each objective, and how sensitive the weights are to the period. Then test any mix you are considering in a backtest over several periods.
What constraints should I set?
A maximum weight per fund is the most useful limit, because unconstrained optimizers often put most of the money in one or two funds. For example, a cap of 30–50% per fund and a small minimum for funds you want to keep. Long-only, with no short positions, is the default; Jagannathan and Ma (2003) showed that this limit on its own reduces the damage done by estimation error.
How much history does the optimizer need?
At least two years of common monthly history to run, and four years to split it into two halves for the out-of-sample check. More is better for volatilities and correlations; for average returns even decades are short. DeMiguel, Garlappi and Uppal (2009) estimated that sample-based mean-variance needs around 3,000 months of data with 25 assets to beat equal weights reliably.
Does it include costs, taxes and currency effects?
No. Portfolios are rebalanced every month at no cost and before taxes. Returns are in each fund’s trading currency, so if you mix US dollar and euro funds the currency moves are not converted. The fund’s own expense ratio is already in its price, and dividends are reinvested.
Which funds can I optimise, and is it free?
Any 2 to 8 of the US and European ETFs covered by our ETF pages, on their monthly total returns. It is free, runs in your browser and needs no account. To optimise any ticker on daily data, with more objectives such as Max Sortino or Min CVaR, use the optimiser in the MEDGE app.
More free tools
- Portfolio analyzerReturn, risk and correlations of up to 10 ETFs
- Monte Carlo simulation10,000 paths on real monthly returns
- Portfolio backtestUp to 10 ETFs on real monthly returns
- DCA calculatorMonthly investing with real returns
- Rolling returnsBest and worst 1–15 year periods
- Efficient frontierRisk and return of every mix of 2–3 ETFs
Source: MarketStack end-of-day prices, total return with dividends reinvested. Figures are historical and descriptive; they are not forecasts and not investment advice. MEDGE Capital does not recommend buying or selling any instrument. Risk disclaimer.