Portfolio optimizer: weights from real past prices
A portfolio optimizer finds the mix of assets that best met a goal in the past. This portfolio optimizer loads real past prices for up to 8 US stocks or ETFs. Then it finds the weights that had the lowest risk, the best Sharpe ratio, or the most return at a risk you set. It is a research tool, not advice. It needs a free account, because it uses our price data.
- Pick a goal, and the tool finds the weights that met it best over the period.
- A cap on each ticker keeps the mix from piling into one name.
- The result is compared with owning equal amounts of each ticker.
- The weights fit the past. They do not tell you what will do well next.
- Small changes in the data can change the weights a lot.
How to use the portfolio optimizer#
Type 2 to 8 tickers, separated by commas, and pick a period. Then choose a goal.
- Best Sharpe ratio finds the mix with the most return for its risk.
- Lowest risk finds the mix that swung the least.
- Most return at a set risk finds the mix that earned the most without swinging more than your target.
Set the most you want in one ticker, and the risk-free rate, which is about what cash pays. Then press Calculate. The tool shows the weights, and a table that compares the mix with equal weights.
The starting tickers and settings are examples. They are not advice.
How does the optimizer work?#
It works out each ticker’s average yearly return, its volatility, and how each pair moved together. Then it searches all the mixes that own each ticker or not, with weights that add up to 100%.
return of mix = sum of (weight × average return)
risk of mix = volatility of the mix's monthly returns, per year
Sharpe ratio = (return of mix - risk-free rate) ÷ risk of mixThe Sharpe ratio is the extra return over cash for each unit of risk. William Sharpe created it in 1966. A higher number means more reward for the swings you sat through.
The search moves weight from one ticker to another, step by step, until no move helps. Then it reports the weights it found.
A worked example#
Say a stock fund returned 8% a year with 16% volatility. A bond fund returned 4% with 6% volatility. Their correlation was 0. Cash paid 3%.
- Stocks alone had a Sharpe ratio of (8% - 3%) ÷ 16% = 0.31.
- Bonds alone had (4% - 3%) ÷ 6% = 0.17.
- The best Sharpe ratio mix was about 41% stocks and 59% bonds. It returned about 5.7% with 7.5% risk.
- Its Sharpe ratio was about 0.35. That beats both funds alone.
- With a target of 10% risk, the best mix was about 61% stocks and 39% bonds. It returned about 6.4%.
The mix beat each fund on its own because the two did not move together. That is the whole idea behind diversification.
Why the optimizer can mislead#
- It trusts the past. It gives the most weight to what did best. That may not do best again.
- It is sensitive. One more year of data can swing the weights from one ticker to another.
- It loves one winner. Without a cap, it often puts most of the money in one ticker. A cap of 40% to 60% gives a more spread-out mix.
- It skips costs, taxes and drift. The math assumes a reset every month at no cost.
A simple equal-weight mix often holds up well against optimized mixes on new data. That is why the tool shows it beside your result.
Common mistakes with portfolio optimizers#
- Treating the weights as advice. They describe a period that is over.
- Testing too few years. A short period rewards whatever was hot.
- Mixing in look-alikes. Three funds that hold the same stocks are really one bet.
- Never testing the result. Check the mix in a backtest with real rebalancing before you rely on it.
Try it on Tactfolio#
The optimizer finds weights. A backtest shows how holding them would have felt, crash by crash. In the Tactfolio strategy builder you can test a mix with rebalancing on decades of prices. The efficient frontier tool shows every mix on one chart. The asset correlation tool shows how your tickers moved together. To see how a plan might hold up over many years, try the Monte Carlo simulator. Learn more about the Sharpe ratio and tactical asset allocation. Every tool is on the free trading calculators page.
Common questions#
What does a portfolio optimizer do?#
It searches for the weights that best met a goal over a past period. The goal might be the least risk or the best return for the risk. It cannot know which mix will do best in the future.
Is the best Sharpe ratio mix the best portfolio?#
It was the best by one measure, over one period. It does not account for your goals, your taxes, or how much drop you can stand. Think of it as a starting point to test, not an answer.
Why does the optimizer put so much in one ticker?#
The math rewards the asset with the best past ratio of return to risk. Without limits it keeps adding that asset. Lower the most in one ticker to force a wider mix.
Why do I need an account for this tool?#
The tool loads years of real daily prices for each ticker. That data is part of Tactfolio, so it needs a free account. The other calculators on this site work with no sign-up.
How often should I rebalance an optimized portfolio?#
Many investors rebalance once or twice a year, or when a weight drifts far from its target. Each trade can cost fees and taxes. A backtest can show how different schedules would have worked.
Sources
- The Sharpe Ratio, William F. Sharpe, Stanford University, accessed October 16, 2026
- The Prize in Economic Sciences 1990, press release, The Royal Swedish Academy of Sciences, accessed October 16, 2026
- Concentrate on Concentration Risk, FINRA, accessed October 16, 2026
- Rebalancing, Investor.gov, U.S. Securities and Exchange Commission, accessed October 16, 2026