Return prediction: machine learning on the S&P 500’s members, corrected for overfitting
← Investment research · Return prediction
This study measures two things on the S&P 500’s point-in-time members, i.e., the stocks in CRSP’s list of index members on the last trading day of the month before, from January 1991 to December 2024. First, how much machine-learning models add to linear models in forecasting each member’s return in the next month, out of sample, i.e., in years on which the model was neither fitted nor chosen. Second, how much of the best result is real once corrected for overfitting, that is, for having tried many versions and kept the best one. The study is in build: it has reached its first milestone, the panel, and its findings on returns are stated when it is complete.
The study follows the method of Gu, Kelly and Xiu (2020)1, reduced to twelve characteristics and the index’s members. A characteristic is a number measured for each member at the end of the month before, such as its market value or its return over the past year. Six models forecast each member’s excess return, i.e., its total return in a month less the one-month Treasury bill rate: least squares on three characteristics and on all twelve, the elastic net, a random forest, boosted trees and a neural network with one hidden layer. Each model is fitted with the squared-error loss, i.e., by minimising the sum of its squared forecast errors. For each test year from 2006 to 2024, a model is fitted on the months from January 1991 to six years before it, its configuration, i.e., one choice of its settings such as a penalty or the depth of a tree, is chosen on the five years before the test year, and the chosen fit forecasts the test year.
Each of the 32 configurations of the six models gives one trial: a portfolio long the tenth of each month’s members with the highest forecasts and short the tenth with the lowest, held from 2006 to 2024 net of costs. A Sharpe ratio is a portfolio’s mean excess return divided by its standard deviation. The overfitting is measured over the 32 trials with two statistics. The deflated Sharpe ratio of Bailey and López de Prado (2014)2 is the confidence, from 0 to 1, that the best trial’s Sharpe ratio is above the highest one that 32 trials with no true effect would be expected to show. The probability of backtest overfitting of Bailey, Borwein, López de Prado and Zhu (2017)3 is the share of the ways of splitting the 2006 to 2024 window into two halves in which the trial that is best in one half ranks in the lower half of the other.
The panel. The panel is a table with one row per member-month, i.e., one member in one month, holding the twelve characteristics and the excess return. From January 1991 to December 2024 it holds 204,520 member-months. In every one of the 408 months each characteristic is present for at least 92.4 per cent of the members. To check that no characteristic uses data from after the end of the month before, 24 months drawn at random were built a second time from data cut at that date, and they equal the full build in all 144,312 cells.
The overfitting statistics. Before either statistic is computed on the study’s returns, both are checked on made-up returns with known answers, at the study’s own 228 months and 32 trials. With no true effect in any trial, the best trial’s deflated Sharpe ratio is above 0.95 in 1 of 4,000 repetitions, where up to 5 per cent would be allowed. The mean probability of backtest overfitting is 0.50 over 1,000 repetitions, the value expected when no trial is better than another. With one trial given a true Sharpe ratio of 1.0 a year, that trial is the best in 98.4 per cent of 1,000 repetitions, the best trial’s deflated Sharpe ratio is above 0.95 in 54.2 per cent, and the mean probability of backtest overfitting falls to 0.10.
The levels of the gates and expectations were written into the repository before the code that tests them ran, and the notebooks mark what was added after the results were known. The stock data are CRSP and Compustat, via Wharton Research Data Services, accessed through Queen Mary University of London, from an extraction of 28 September 2026. The market’s daily excess return and the one-month bill rate come from Kenneth French’s data library4. The universe and the monthly returns come from the data layer of Stock-level index tracking5, copied unchanged, and the copy reproduces that study’s 440,724 member-months from January 1926 to December 2024. The stock data are licensed, so the repository holds code, tests and aggregates and none of the data. The code is on GitHub6.
Terms
- Point-in-time members: the stocks in CRSP’s list of index members on the last trading day of the month before.
- Member-month: one member in one month.
- Characteristic: a number measured for each member at the end of the month before, such as its market value or its return over the past year.
- Excess return: a member’s total return in the month less the one-month Treasury bill rate.
- Out of sample: forecast for a year on which the model was neither fitted nor chosen.
- Configuration: one choice of a model’s settings, such as a penalty or the depth of a tree.
- Squared-error loss: fitting a model by minimising the sum of its squared forecast errors.
- Trial: the long-short portfolio of one configuration, held from 2006 to 2024 net of costs.
- Sharpe ratio: a portfolio’s mean excess return divided by its standard deviation.
- Deflated Sharpe ratio: the confidence, from 0 to 1, that the best trial’s Sharpe ratio is above the highest one that 32 trials with no true effect would be expected to show.
- Probability of backtest overfitting: the share of the ways of splitting the 2006 to 2024 window into two halves in which the trial that is best in one half ranks in the lower half of the other.
- Gate: a test fixed in advance that the data or the code must pass, which stops the build if it is not met.
- Expectation: a test of a result fixed in advance, reported as a finding if it is not met.
Notes
- Gu, S., Kelly, B. and Xiu, D. (2020). Empirical asset pricing via machine learning. Review of Financial Studies 33(5), 2223 to 2273. https://doi.org/10.1093/rfs/hhaa009
- Bailey, D. H. and López de Prado, M. (2014). The deflated Sharpe ratio: correcting for selection bias, backtest overfitting, and non-normality. Journal of Portfolio Management 40(5), 94 to 107. https://doi.org/10.3905/jpm.2014.40.5.094
- Bailey, D. H., Borwein, J., López de Prado, M. and Zhu, Q. J. (2017). The probability of backtest overfitting. Journal of Computational Finance 20(4). https://doi.org/10.21314/JCF.2016.322
- Kenneth French's data library, the daily market excess return and the one-month bill rate.
- Stock-level index tracking, the project page.
- ml-return-prediction-backtest-overfitting, the repository on GitHub.
Other projects
Portfolio construction
Optimal versus naive diversification
Under a long-only index-tracking mandate on French's 49 industries, 1979 to 2026, each of five covariance estimators forecasts less tracking error than its portfolio realises: the realised active return is 22 to 61 per cent more volatile than forecast. The replication of DeMiguel, Garlappi and Uppal (2009) reproduces 29 of the 30 out-of-sample Sharpe ratios it tests within 0.03 of the published values, 26 of 27 with the value-weighted market counted once.
Ownership and prices
Climate risk as an equity signal
An ownership graph linking 328 ownership entities in the US and developed Europe, 302 of them listed companies with a price series, to 5,115 asset holdings, built from Global Energy Monitor's free tracker. Of 19 apparent ownership changes drawn at random and checked by hand, 12 had no corporate event behind them.
Signal evaluation
Volatility estimation and position sizing on Ken French's equity factors, replicating Moreira and Muir (2017) and the real-time critique of Cederburg, O'Doherty, Wang and Yan (2020). Scaled by the inverse of last month's realised variance, a factor's Sharpe ratio is higher than the original's by a margin that is statistically significant at the 5 per cent level for momentum alone when each of the six factors is tested on its own, and for no factor after Holm's correction for the six tests. In the 136 months after Moreira and Muir's sample no factor's difference is statistically significant, and for the six volatility-managed factors the intervals are too wide to rule out the differences found on their sample.
Stock-level index tracking
A point-in-time benchmark, a long-only mandate, and its performance attribution by sector
Rebuilds the S&P 500 month by month from CRSP's list of members, at a tracking error of 11.5 basis points a year from 1926 to 2024 against CRSP's own return of the same list, and runs a long-only index-tracking mandate on it from 1999 to 2024, with its active return attributed by sector. The portfolios realise 78.9 to 83.6 basis points a year of tracking error, and each of four covariance estimators forecasts less: the realised active return is 48 to 85 per cent more volatile than forecast. Index changes require 11.4 per cent of the turnover of the portfolio built with Ledoit-Wolf shrinkage.
Asset allocation
Runs a real-money portfolio under rules published before the first order, with every later change dated in the repository: two UCITS ETFs at 70/30, a monthly cycle with pre-trade checks, look-through exposure and ex-ante risk on a public dashboard.
