Experiment 004 · Five S&P 500 Sectors
Can a Bandit Beat Three Very Human Trading Rules?
Suppose we have $1,000 to divide among technology, health care, energy, financials, and consumer staples. We can let a model choose the split, but we can also try a few rules that probably feel familiar to anyone who has watched an investment fall: sell it, chase whatever is going up, or buy more while it is cheap. Which approach actually works best?
why use sectors?
Let's Start With the Five Investments
Each fund holds many companies from one part of the economy. That gives us investments that can behave quite differently without letting one company's earnings report take over the whole experiment.
The Result
So, Who Made the Most Money?
Every strategy begins with the same $1,000 and only gets to use weeks that have already happened. The model looks at several pieces of market history. The other three strategies each follow one simple rule.
Loading the frozen result…
What are the three human rules?
The Panic Seller
If the largest holding loses at least 2% and another sector does at least 1 percentage point better, put 60% into the better sector.
The Performance Chaser
If one sector beats every other sector by at least 1.5 percentage points, put 60% into that week's winner.
The Dip Buyer
If one sector loses at least 2% and trails the next-worst sector by at least 1 percentage point, put 60% into the sector that just fell.
If nothing triggers a rule, it does nothing. The remaining 40% is divided evenly among the other four sectors. Every choice uses last week's returns, and every trade costs 0.10% of the money moved.
Week by Week
How Did the Model Split the Money?
Each line shows the percentage placed in one sector. Together, the five lines always add up to 100%.
so what happened?
What Did We Learn?
It Beat the Panic Seller
The model finished at $1,382, while the panic seller reached $1,249. The model also changed its mind gradually instead of moving most of the portfolio after a bad week.
The Two Simple Rules Won
The dip buyer finished first at $1,520, followed by the performance chaser at $1,494. Over these two years, both recent rebounds and continued sector runs were strong enough to beat the model.
Two Years Is Definitely Not Forever
This is a short test containing just over 100 weekly choices. It tells us what happened during this particular market, not what these rules will do in the next one.
Where Do We Go From Here?
- Run the same four rules over several different periods instead of just this one.
- See what happens to the dip buyer during a long decline rather than a quick drop and recovery.
- Choose all of the cutoffs using an earlier training period, then leave the final test period completely untouched.
inside the model
So How Does the Bandit Choose?
The model can divide the money among all five sectors, but it must keep at least 5% in each one. It estimates which sectors are more likely to do well next week, turns those predictions into a split, and tries not to completely rearrange the portfolio every Friday.
- 01
Start With What We Know
Before each week, the model compares every sector's four-week return, thirteen-week return, volatility, and drawdown with the average of the other sectors. Everything comes from prices that were already known at the time.
- 02
Make Five Predictions
An online ridge regression estimates how each sector might perform relative to the five-sector average next week. The model starts with equal allocations and learns only after each week is finished.
- 03
Turn Predictions Into a Split
Higher predictions receive more money, while uncertain predictions are pulled closer together. Every sector keeps at least 5%, so the model can tilt but never make an all-or-nothing bet.
- 04
Don't Move Too Fast
The model balances its new prediction against last week's allocation. A small change is easy to make. A large change needs a much stronger prediction. This keeps the portfolio from bouncing around every week.
for those who want the symbols
The Math Zone
Let i identify one of the five sectors, t be a week, xi,t its past-only market context, and wi,t its share of the portfolio.
What the model sees
The bounded features compare sector i with the other sectors using prices known before week t.
Relative return
Online ridge regression makes one relative-return prediction for each sector.
From scores to percentages
A softmax converts five confidence-adjusted scores into percentages. The five 5% minimums leave 75% for the model to distribute.
Don't forget last week
One quarter of the new allocation comes from this week's target and three quarters comes from the previous allocation.
Notes & sources
The three profiles are intentionally simplified trading rules, not diagnoses of real investors. Their ideas echo research on loss aversion ↗, buying recent winners ↗, and market overreaction and reversals ↗. Barber and Odean’s study also found that frequent individual trading was associated with worse performance ↗. Krishnamurthy et al. study contextual bandits with continuous actions ↗, while Boyd et al. incorporate transaction costs into portfolio optimization ↗. Adjusted daily prices come from the frozen Yahoo Finance snapshot. This experiment is for education and is not investment advice.
