Francisco A. Delgado, PhD Finance · Economics · Technology · GeopoliticsFinanzas · Economía · Tecnología · Geopolítica

Can You Use AI to Beat the S&P 500? Only Theoretically

Francisco A. Delgado, PhD Nov 11, 202611 nov. 2026 · 9 min

Abstract: I used an AI assistant (Claude) to answer an old question: can a smarter mix of ETFs beat the S&P 500? In a few hours it gathered seventeen years of prices, wrote the optimization, tested dozens of variations and measured the costs, work that would once have taken weeks. The rule we tested holds 12 ETFs, SPY and the eleven Vanguard sector funds: keep at least 35% in SPY, cap volatility at SPY’s level, and each month put the rest in the sectors with the best five-year record. From October 2009 to October 2026 it returned 14.65% a year against 14.20% for SPY, with the same volatility, and turned $100,000 into $1,033,177 against $966,568. On paper, the AI-built portfolio won. In practice, the edge is thin and uneven: it came from a few strong years, for technology in 2019, 2020 and 2023 and for energy in 2026; the portfolio was behind SPY until the end of 2025, and it traded about 70% of its holdings every year. Once trading costs of 0.25% or any tax on realized gains are included, the advantage disappears. Conclusion: AI makes it fast and cheap to find a strategy that beats the S&P 500, but only theoretically; after real-world costs, SPY still wins.

The idea

SPY is the sum of its sectors. If we own the sectors separately, we can choose how much of each to hold: more of the sectors that are doing well, less of those that are not. The question is whether that freedom adds return, or only adds risk, trading and cost.

What the AI did, and what it cannot do

I set the question and the rules; the AI did the heavy lifting. It downloaded monthly prices for every fund, wrote the code for the optimization, ran it month by month so that each decision used only data available at the time, repeated it for different minimum weights in SPY, and then added trading costs and taxes. It also drafted the charts and tables in this article. Testing an idea like this used to require a programmer, a data subscription and weeks of work; now it takes an afternoon.

What the AI cannot do is see the future. The rule it ran is only as good as the assumption behind it, that the sectors that did best over the last five years will keep doing well next month. AI makes testing cheap, but it does not change the arithmetic of markets: the same costs, taxes and luck apply to everyone. Note, too, that the optimization itself is a conventional quantitative method, not a predictive AI model: the AI built and ran it, but nothing in it forecasts the future.

The method

The portfolio can hold 12 ETFs: SPY and the eleven Vanguard sector funds (VGT, VFH, VHT, VCR, VOX, VIS, VDC, VDE, VPU, VAW and VNQ). At the end of each month, the weights for the next month are chosen from the previous 60 months of returns, following three rules:

  • Highest return. Choose the mix with the highest average return over those five years.

  • No more risk than SPY. The mix’s volatility over the same five years may not exceed SPY’s.

  • A core in SPY. At least 35% stays in SPY; no fund may be held short.

In mathematical terms, with w the weights, μ the average monthly returns and Σ the covariance matrix of the previous 60 months, each month the rule solves:

maximize w′μ

subject to √(w′Σw) ≤ σ(SPY), w(SPY) ≥ 35%, w₁ + … + w₁₂ = 100%, w ≥ 0

Those weights are then applied to the following month’s actual returns, and the window moves forward one month. The test only uses information available at the time. Because the youngest sector funds began in September 2004, the first five-year window ends in September 2009, so the results cover October 2009 to October 2026 (205 months), with dividends reinvested.

The result: ahead of SPY, by a little

Measure (Oct 2009–Oct 2026) 12-ETF portfolio SPY
Return a year 14.65% 14.20%
Volatility 14.3% 14.3%
Worst fall (month-end) -25.8% -23.9%
Gap vs SPY (tracking error) 4.8% —
Months beating SPY 50% —
Return a year, Oct 2009–Dec 2025 13.68% 14.20%
Return a year, May 2012–Oct 2026 15.57% 14.30%
Return / volatility 1.02 0.99
Correlation with SPY 0.945 1.000
Share of portfolio traded a year 70% 0%
$100,000 became $1,033,177 $966,568

Table 1. Out-of-sample results before costs and taxes. Source: Yahoo Finance dividend-adjusted month-end prices; author’s calculations.

Before costs, the portfolio earned 0.45 points a year more than SPY with the same volatility, and ended about $66,600 ahead on $100,000 (Figure 1). Its worst fall was slightly deeper, and it beat SPY in only half the months. The result is also sensitive to the starting date: measured from May 2012 the edge grows to 1.3 points, while up to December 2025 the portfolio was 0.52 points a year behind.

Figure 1. Growth of $100,000 invested in September 2009, before costs and taxes, dividends reinvested. Source: Yahoo Finance; author’s calculations.

The gain was lumpy. The portfolio beat SPY in 8 of 16 full calendar years; a few years did most of the work, above all 2019, 2020 and 2023 (technology) and 2026 (energy), while 2012, 2016 and 2025 cost it 6.5–9.5 points each (Figure 2). An investor would also have needed the patience to stay behind SPY for long stretches (see Figure 5).

Figure 2. Calendar-year return of the portfolio minus SPY, in percentage points. *2009 covers October–December; 2026 runs to October. Source: author’s calculations.

What the portfolio held

SPY always stayed at its 35% minimum. On average the rest went to technology (VGT, 22.5%), health care (VHT, 11%), consumer staples (VDC, 9%), energy (VDE, 7%) and utilities (VPU, 7%) (Figure 3). Industrials were never held, and communication services only briefly.

Figure 3. Average weights, October 2009–October 2026. Source: author’s calculations.

The pattern is a barbell. Technology had the highest return of any sector, but holding a lot of it would break the volatility limit, so the optimizer paired it with the calmest sectors (health care, consumer staples and utilities) to bring the portfolio’s risk back down to SPY’s. Energy added a sector that often moves on its own (Table 2).

ETF Average weight Role in the portfolio Return a year Volatility Beta vs SPY
SPY 35.0% Required core 11.05% 14.7% 1.00
VGT 22.5% Growth engine 16.07% 19.6% 1.19
VHT 11.0% Defensive, solid return 10.91% 14.1% 0.72
VDC 9.1% Volatility buffer 9.88% 12.0% 0.58
VDE 7.0% Moves on its own (correlation 0.60) 8.90% 26.6% 1.09
VPU 6.7% Low-beta stabilizer 9.42% 14.2% 0.49

Table 2. The six funds that made up 91% of the portfolio on average. Return, volatility and beta are for October 2004–October 2026. Source: Yahoo Finance; author’s calculations.

The average hides how much the weights moved. The rule buys whatever did best over the last five years, so it held almost no VGT until 2017 (apart from two months in 2012), then 40–50% from 2018 to 2024, and cut it to about 20% in 2025 (Figure 4). Energy followed the same pattern later: the rule raised it to an average of 22% in 2025 and 36% in 2026, and energy’s 58% gain this year produced most of the portfolio’s 2026 lead. It is a momentum strategy: it works while trends last and lags when they turn.

Figure 4. Monthly weight of VGT in the portfolio. Source: author’s calculations.

Does the minimum in SPY matter?

Minimum in SPY Return a year Gap vs SPY Worst fall Traded a year
15% 14.63% 5.7% -26.0% 91%
25% 14.65% 5.2% -25.9% 80%
35% 14.65% 4.8% -25.8% 70%
50% 14.53% 4.0% -25.6% 58%
65% 14.47% 3.5% -25.2% 43%
SPY only 14.20% — -23.9% 0%

Table 3. Results by minimum SPY weight, October 2009–October 2026, before costs and taxes. Source: author’s calculations.

Every minimum from 15% to 65% ended 0.27–0.45 points a year ahead of SPY before costs. Lowering the minimum barely raises the return but increases the gap with SPY and the amount traded. A 35% minimum captures essentially all of the gain.

What it costs

The results so far ignore two real costs. First, trading: each month the portfolio is rebalanced, and about 70% of it changes hands in a year. Every purchase and sale pays a bid-ask spread and, with many brokers, a commission. Second, taxes: SPY held alone defers its gains until it is sold, while the rotating portfolio realizes gains every year.

Table 4 repeats the test with those costs. Trading costs are charged on every dollar bought or sold. Taxes are charged each December on net realized gains, with losses carried forward; at the end both portfolios are sold and pay tax on their remaining gains, so the comparison is after all taxes.

Trading cost per $ traded Tax on realized gains 12-ETF portfolio SPY Difference (points)
0.00% 0% 14.65% 14.20% +0.45
0.10% 0% 14.48% 14.19% +0.28
0.25% 0% 14.22% 14.18% +0.04
0.00% 15% 13.20% 13.24% -0.04
0.10% 15% 13.05% 13.23% -0.19
0.25% 15% 12.81% 13.22% -0.41
0.00% 30% 11.89% 12.13% -0.24
0.10% 30% 11.75% 12.12% -0.37
0.25% 30% 11.53% 12.11% -0.58

Table 4. Annual return after trading costs and taxes, October 2009–October 2026, with both portfolios sold at the end and a single tax rate for all realized gains. Dividend taxes, which affect both alike, are left out. Source: author’s calculations.

The edge is too small to survive. A trading cost of 0.25% per dollar traded, realistic for many small investors once commissions and spreads are included, cuts it to +0.04 points. Any tax on realized gains erases it: at 15% the portfolio trails SPY by 0.04 points even with free trading, and with 0.25% costs and a 30% tax it trails by 0.58 points a year, ending at $645,278 against $704,906 in SPY. Only an investor who trades almost for free inside a tax-exempt account keeps the full gain.

Why only theoretically

Costs and taxes are not the only problem. Three more reasons make the paper result hard to capture in practice.

Almost nine years behind SPY. Measured by total money made since the start, the portfolio was behind SPY continuously from September 2011 to May 2020, and again from July 2024 to January 2026 (Figure 5). An investor would have watched the strategy lose to the index for most of a decade before it pulled ahead. Very few people, or advisors, stick with a strategy through that.

Figure 5. Value of the portfolio relative to SPY (100 = equal); below 100 the portfolio had made less money than SPY since October 2009. Before costs and taxes. Source: author’s calculations.

The S&P 500 is already a momentum strategy, and a free one. Because the index weights companies by market value, winners automatically grow in weight and losers shrink, with no trading at all. A rule that chases winners by trading every month competes with a benchmark that does something similar at no cost, which is why the extra gain is so small.

The 35% minimum was chosen with hindsight. Each month’s weights used only past data, but the 35% minimum was picked after comparing several minimums over the whole period. That choice is itself a small look into the future, so the true out-of-sample result is likely a little worse than reported.

Cautions

  • The edge is not statistically reliable. An extra 0.45 points a year with a 4.8% gap from SPY could easily be luck (t-statistic 0.35; about 2 would be needed).

  • It depends on trends continuing. The rule buys past winners. A long reversal, like 2000–2002 for technology or 2014–2020 for energy, would hurt it.

  • Time and discipline. Rebalancing twelve funds every month takes work and attention.

Conclusion

With an AI assistant, I built and tested in an afternoon a portfolio of SPY and sector ETFs that beat the S&P 500: with a 35% SPY core and no extra volatility, it gained about half a point a year over seventeen years, mainly by leaning into technology, and in 2026 energy, at the right time. But the gain is small, uneven and statistically uncertain, and it depends on trading every month. Once realistic trading costs and taxes are counted, it disappears. AI can help you beat the S&P 500, but only theoretically. For most investors, holding SPY, or a lower-cost twin such as VOO or IVV, remains the better choice. The real value of AI here is not a winning formula; it is the ability to test an idea honestly, quickly and cheaply before risking money on it.

Questions about your portfolio?

I advise investors independently, using low-cost ETFs.