Back to Calculators

Free Portfolio Optimizer

Build maximum-Sharpe, minimum-variance, CVaR and Black-Litterman portfolios from real stock data, and see where they sit on the Markowitz efficient frontier.

Input Parameters

Search for any stock by name or ticker symbol. Selected tickers will be comma-separated.

Live market data service is currently unavailable. Please try again later.

How to use the portfolio optimizer

  1. Add your stocks. Type a company name or ticker and pick it from the list. Two assets is the minimum; 5 to 15 gives more meaningful diversification.
  2. Choose the history. The analysis period sets how many years of prices are used to estimate returns, volatilities and correlations. The data frequency sets whether daily, weekly or monthly returns are used.
  3. Pick an optimization method. Maximize Sharpe ratio is the usual starting point. The table below explains when each method fits.
  4. Read the results. You get the optimal weights, the expected annual return and volatility, the Sharpe ratio, the efficient frontier chart and the past cumulative return of the portfolio against each stock. Export them to CSV if you want to keep them.

What a portfolio optimizer does

A portfolio optimizer chooses how much to put in each asset so that the mix has the best trade-off between return and risk. The idea comes from Harry Markowitz's 1952 paper Portfolio Selection, the basis of Modern Portfolio Theory: what matters is not the risk of each stock on its own but how the stocks move together. Two volatile stocks that are weakly correlated can form a portfolio that is less risky than either of them.

For weights w, expected annual returns μ and the covariance matrix Σ of the assets:

Portfolio return: μp = wTμ = Σ wi μi

Portfolio volatility: σp = √(wTΣw)

The two most common optimizations are:

Minimum variance: minimize wTΣw

Maximum Sharpe: maximize (wTμ − rf) / √(wTΣw)

Both are solved subject to Σ wi = 1 (fully invested) and wi ≥ 0 (no short selling), which is how this tool works. Expected returns and covariances are estimated from the price history you choose and annualized with 252 trading days; the risk-free rate rf is set at 2%. Repeating the minimum-variance problem for every target return traces the efficient frontier: the set of portfolios with the highest return for each level of risk. The maximum Sharpe portfolio is the point on that curve with the best return per unit of volatility (see the Sharpe ratio explained).

The six optimization methods compared

MethodWhat it optimizesUse it whenWatch out for
Maximize Sharpe ratioExcess return per unit of volatilityYou want the best risk-adjusted mix (the usual default)Very sensitive to the estimated returns
Minimize riskLowest portfolio volatilityCapital preservation; you distrust return forecastsCan load up on the calmest assets
Maximize returnHighest expected returnSeeing the return end of the frontierWithout shorting or leverage it puts 100% in the single best past performer
Minimize CVaRAverage loss in the worst daysYou care about crashes more than day-to-day swingsNeeds enough history to contain bad periods
Target returnLowest volatility for a return you setYou have a required return, for example for a planThe target must lie within the achievable range
Black-LittermanBlends market-implied returns with your viewsYou have specific views and want stable weightsResults depend on your confidence levels

Worked example: three asset classes

To show what the optimizer does, take three assets with these assumed annual figures (illustrative only, not forecasts): stocks with 8% expected return and 16% volatility, bonds with 4% and 6%, and gold with 5% and 15%. Correlations are 0 between stocks and bonds, 0.1 between stocks and gold, and 0.3 between bonds and gold. The risk-free rate is 2%.

PortfolioStocksBondsGoldReturnVolatilitySharpe
Equal weight33.3%33.3%33.3%5.67%8.29%0.44
Minimum variance12.1%85.5%2.4%4.51%5.61%0.45
Maximum Sharpe28.9%65.3%5.8%5.21%6.35%0.51
100% stocks100%0%0%8.00%16.00%0.38

The maximum Sharpe portfolio gives up less than half a point of return against the equal-weight mix (5.21% vs 5.67%) but cuts volatility by almost two points (6.35% vs 8.29%), so it earns more per unit of risk. Its large bond weight comes from the zero stock-bond correlation: bonds lower the portfolio's risk more than their own return costs.

Now raise gold's expected return from 5% to 6% and keep everything else the same. The optimal gold weight roughly doubles, from 5.8% to 11.9% (stocks 28.0%, bonds 60.1%). A one-point change in one input moved the allocation a lot, and that sensitivity is the main thing to understand before trusting any optimizer's output.

Limitations and good practice

  • The past is only an estimate. The optimizer uses historical averages as expected returns. Returns are far harder to estimate than volatilities and correlations, and errors in them drive the weights. Richard Michaud called mean-variance optimizers "error maximizers" for this reason.
  • Expect concentrated weights. With few assets or a short period, maximum Sharpe often puts most of the money in one or two recent winners. Use a longer period, more assets, minimum variance or Black-Litterman to get steadier weights.
  • Volatility is not the only risk. Variance treats gains and losses alike and assumes well-behaved returns. If crashes worry you, compare with the CVaR method or check tail risk in our VaR and CVaR calculator.
  • Rebalance on a rule. Optimal weights drift as prices move. Re-run the optimizer and rebalance on a schedule or with tolerance bands; the portfolio rebalancing calculator shows the trades.
  • Check the factors. A portfolio of different stocks can still be one big bet on the market or on growth stocks. Our factor analysis tool shows those exposures.

Risk note: results are based on past prices and are for education and research only. They are not investment advice and do not predict future returns. See our terms of service.

CVaR and Black-Litterman in detail

About Conditional Value at Risk (CVaR)

Conditional Value at Risk (CVaR), also known as Expected Shortfall, is an advanced risk measure that focuses on the average loss in the worst-case scenarios. Unlike traditional variance-based optimization which treats upside and downside volatility equally, CVaR specifically addresses tail risk: the potential for extreme negative returns.

CVaR optimization is particularly valuable for investors who are concerned about downside protection and want to create more robust portfolios that can better withstand market stress events. This approach aligns well with how most investors perceive risk: not as symmetric volatility, but as the threat of significant losses.

About Black-Litterman Model

The Black-Litterman model, developed by Fischer Black and Robert Litterman at Goldman Sachs, enhances Modern Portfolio Theory by combining market equilibrium with investor views. This approach helps solve key limitations of traditional optimization:

  • Reduces extreme allocations that can occur in traditional optimization
  • Provides more intuitive, stable portfolios that better match investor expectations
  • Allows explicitly incorporating your views on specific assets with varying levels of confidence
  • Uses market capitalization as a starting point (prior), then adjusts based on your views

Understanding Your Results

The Black-Litterman model blends market expectations with your personal views rather than completely replacing them:

  • Market Impact: Assets with larger market caps have stronger priors that are harder to override
  • Confidence Levels: A 50% confidence means your view gets 50% weight vs. market expectations
  • Portfolio Position: Black-Litterman portfolios may appear off the efficient frontier because they're optimized using blended returns instead of purely historical data

How to Get More Impact from Your Views:

  • Use higher confidence levels (80-100%) for stronger conviction views
  • Uncheck "Use Market Cap Weights as Prior" if market caps are highly concentrated in few assets
  • Express views on multiple assets for a more balanced portfolio adjustment

Frequently asked questions

Is this portfolio optimizer free?

Yes. There is no account and no sign-up. Enter your tickers, choose a method and the optimizer runs on historical daily prices from our database.

What is the difference between maximum Sharpe and minimum variance?

Minimum variance ignores expected returns and finds the least volatile mix. Maximum Sharpe uses expected returns too and finds the mix with the highest excess return per unit of volatility. Minimum variance is usually more stable because it does not depend on return estimates, which are the noisiest input.

How much historical data should I use?

Three to five years is a common choice: long enough to include different market conditions, recent enough to reflect how the companies look today. One year or less makes the weights chase recent winners. Weekly or monthly data reduce day-to-day noise but leave fewer observations.

Why does the optimizer put most of my money in one or two stocks?

Because it treats past average returns as if they were known with certainty, and small differences in them get magnified into big weight differences (see the worked example above). Add more assets, use a longer period, or try minimum variance or Black-Litterman for more balanced weights.

Should I use mean-variance or CVaR optimization?

Mean-variance penalizes all volatility, up and down. CVaR only looks at the average loss on the worst days, so it suits investors who mainly fear crashes and holdings with skewed or fat-tailed returns. Running both and comparing the weights is a good robustness check. Our guide to CVaR portfolio optimization covers the method in depth.

Can a portfolio optimizer predict future returns?

No. It finds the best mix for the inputs it is given, and here those inputs come from the past. Treat the weights as a starting point for your own judgment and rebalancing rules, not as a forecast.

Sources

  • Markowitz, H. (1952). Portfolio Selection. Journal of Finance, 7(1), 77–91.
  • Sharpe, W. F. (1966). Mutual Fund Performance. Journal of Business, 39(1), 119–138.
  • Michaud, R. O. (1989). The Markowitz Optimization Enigma: Is "Optimized" Optimal? Financial Analysts Journal, 45(1), 31–42.
  • Black, F. and Litterman, R. (1992). Global Portfolio Optimization. Financial Analysts Journal, 48(5), 28–43.
  • Rockafellar, R. T. and Uryasev, S. (2000). Optimization of Conditional Value-at-Risk. Journal of Risk, 2(3), 21–41.

Free Trading Math & Risk Cheat Sheet

Every key formula in one PDF: breakeven win rates, expectancy, position sizing, drawdown recovery, volatility drag, VaR and CVaR. Plus occasional emails when we publish new quant tools.

No spam. See our privacy policy.