QUBO Portfolio Optimizer

Loading universe info...

⚖️

Build a portfolio

Solved live as a real QUBO (cardinality-constrained mean-variance) via simulated annealing — takes about 20-30 seconds.

Risk tolerance
Number of stocks
10
Capital to invest
$
Current holdings (optional)

If you already own stocks, list them as TICKER:DOLLARS, comma-separated. New picks will be steered away from what's correlated with what you already hold, and won't repeat a ticker you're already in. Tickers outside the S&P 500 work too (a few extra seconds to fetch real price history for them).

Must include (optional, up to 3)
Lean toward a sector (optional)

"Must include" forces up to 3 tickers into the K stocks (S&P 500 or not -- outside tickers just take a few extra seconds to fetch real price history for); a sector lean forces in that sector's single best-scoring candidate, plus a smaller boost for the rest of the sector. Either way, the optimizer fills the remaining slots around your picks -- risk flags below still apply honestly regardless.

Finding the optimal number of holdings...
Solving...
📊

Risk vs. return: full universe, your selection highlighted

Each dot is one S&P 500 ticker. Hover any dot for details.

S&P 500 universe
Selected
Combined portfolio (equal-weighted)
📈

Projected range of outcomes

A statistical simulation (3,000 random paths), not a forecast — see the note below before reading too much into it.

⚠️
This is not a prediction. Nobody can reliably predict stock prices — if they could, this would not be a free tool. This chart shows the range of outcomes you'd get by simulating thousands of random paths using this portfolio's own historical return and volatility. The width of the band is the actual point: the future is uncertain, and the assumption underneath all of this is that the next few years behave statistically like the past 3 years did, which is not guaranteed.
Time horizon
Add over time (optional)
$
Every
month(s)
📋

Selected portfolio

🤝

Hedge sizing calculator

If you wanted to offset this portfolio's risk with a hedge, here's the math for how much — not a recommendation to hedge, or a signal for when.

Hedge instrument volatility
%

Default 18% is roughly typical for a broad market index (like SPY) historically — change it if hedging with something more or less volatile.

Common hedge instrument categories

Broad-marketSPY, VOO
Tracks the S&P 500 as a whole — offsets general market-wide swings, not any specific concentration in your picks.
Sector-specificXLK, XLF, XLE, XLV, XLY
Tracks one sector (tech, financials, energy, health care, consumer discretionary) — offsets risk that's concentrated in that sector more precisely than a broad-market fund would.
Inverse/short fundsSH, PSQ
Moves opposite the market by design — a way to get downside protection without shorting individual stocks directly.

These are examples of instrument types, not a recommendation — which one (if any) fits depends on your own broader financial picture, which this tool doesn't know.

How the stock-count recommendation works

For every count from 3 to 25 stocks, the tool builds the best possible equal-weighted portfolio of exactly that size (greedy selection, then a local-search polish), and scores each one with the same objective the main optimizer uses:

score = risk_aversion × variance − expected_return
(lower score is better)

Adding stocks helps at first — spreading equal-sized bets across more names reduces company-specific risk. But because every position is forced to the same equal share, each additional, weaker stock doesn't just add harmless diversification — it dilutes your best picks by forcing them to give up part of their equal share. Past some point that dilution costs more than the extra diversification is worth, so the score gets worse again. That's why the curve has a real low point instead of just improving forever — the recommended count is exactly that minimum.

Your risk tolerance changes how heavily variance is penalized in that score, which is why Conservative, Balanced, and Aggressive can each recommend a different count for the exact same stock universe. If your capital is small enough that this count would push any single position below the minimum position size, the recommendation is capped lower instead — a practical floor, not part of the math.

How hedging works, and what this calculator does

Hedging, in plain terms: it means taking on a second position that's expected to move opposite your main portfolio, so a loss in one is offset by a gain in the other. It doesn't make your portfolio go up more — it narrows the range of outcomes in both directions: smaller potential losses, but also smaller potential gains, since you're giving up some upside in exchange for that protection. People hedge when they want to stay invested through a rough stretch without selling anything, not to make extra money.

What this tool actually calculates: it sizes a hedge by matching volatility (how big the swings are), not full risk. It takes your portfolio's dollar value and annualized volatility, and the hedge instrument's own volatility (editable above — 18% defaults to roughly what a broad market index like SPY has historically had), then works out how large a position in that instrument would need to be so its typical swing is about the same size as your portfolio's typical swing.

1-year swing ≈ portfolio value × portfolio volatility
hedge ratio = portfolio volatility ÷ hedge instrument volatility
hedge notional = portfolio value × hedge ratio

What it deliberately leaves out: correlation. A hedge only actually protects you if the instrument moves opposite your portfolio when it matters. This calculator assumes that direction is right and only matches the size of the swings — it doesn't check whether your chosen instrument is really negatively correlated with your holdings. If it isn't (or worse, moves the same direction), this sizing wouldn't protect you the way it looks like it would on paper.

This is sizing math only, for if you decide to hedge — it never tells you whether you should, or which instrument to use. Those calls are yours.

How the news-sentiment signal works, and its real limits

What it does: once a week, every S&P 500 ticker's ~10 most recent Yahoo Finance headlines are scored by an automated sentiment analyzer and averaged into a single number per stock, from −1 (very negative) to +1 (very positive). If you turn this on, that score nudges the stock's expected return up or down by up to ±5 percentage points before the optimizer picks — a real number pulled into the math, not decoration.

return adjustment = average headline sentiment × 0.05
(applied only to selection, capped at ±5 percentage points)

What "automated" actually means here, honestly: this is a general-purpose sentiment tool (VADER), not a financial analyst and not a language model reading for meaning. It reliably catches sharply negative headlines — recalls, lawsuits, a stock "plunging" — but it's weak on common positive financial phrasing. A headline like "Company beats earnings estimates, raises full-year guidance" scores as completely neutral, not positive, because words like "beats" and "raises" aren't inherently positive outside a financial context. Treat this as a real but crude signal, not equivalent to actually reading the news.

It's off by default for exactly this reason. When it's on, each stock's score is shown in the results table so you can see what moved the pick, not just that something did.