Top-N Market Cap — selection & rebalancing

How the top stocks are selected

At each rebalance, the engine scores every company in the S&P 500 by market capitalization:

market cap = shares outstanding × that month's closing price

It sorts all ~500 companies by that score from largest to smallest and keeps the top N you chose (3, 5, or 10). Those N are held in equal weight — e.g. for N=5, each name is 20% of the portfolio. Because the biggest companies stay big, the basket changes slowly and is usually dominated by mega-caps (Apple, Microsoft, Nvidia, Alphabet, Amazon…).

When it buys and sells (the rebalance)

All prices are month-end closes — the closing price on the last trading day of each month. The trade is modeled at that close. For Market Cap, the ranking and the trade happen on the same day (the engine ranks by that day's close and trades at that day's close — there is no look-ahead, since only that day's prices are used).

Worked example — N = 5, quarterly rebalance

Say you start in January 2021 with $10,000 plus $1,000/month, N = 5, rebalancing every 3 months.

So a "March rebalance" means: decide and trade at the last trading day of March, at the close — not the first day of April, and not intraday. Between rebalances nothing is bought or sold except the monthly top-up.

Why month-end close? Monthly closing prices keep the dataset auditable and reproducible. The simulator does not model a specific clock time, the next day's open, or intraday execution — every trade is assumed to fill at the month-end closing price.

The Rebalance style controls what happens to the weights at each rebalance — a full equal-weight reset, a reset only when the line-up changes, or trading just the additions and removals.

Run this backtest →