Case studyESC499 thesis
SupervisorProf. Roy H. Kwon
Mechanical & Industrial
Engineering, U of T
StatusPreliminary studies closed
selector in build
PeriodSep 2026 – Apr 2027

A backtest the model has already read

The thesis asks whether a large language model, given only what a company had filed by a given date, can pick long and short candidates from the S&P 500 that are worth holding after trading and borrowing costs, and whether knowing the market regime helps it do so.

The design has four parts. An evidence packet holds the text a firm had filed by the decision date, taken from its 10-K and 10-Q filings and stamped with the time the SEC accepted it. A language model reads the packet and labels the stock long, short or neutral, with a reason. A long-short mean-variance optimizer sets the weights under exposure caps and a grid of cost assumptions. And a regime-switching factor model, from Costa and Kwon (2020), can inform the selector’s prompt, the optimizer’s inputs, both, or neither, which gives four conditions to compare. Everything is backtested monthly, net of costs, with every model call written to a ledger before its result is used.

ONE MONTH ยท EVERY STOCK IN THE S&P 500Regime modelCosta and Kwon (2020)Switched on or off for eachstage: four conditionsinto the promptinto the inputsEvidence as of t10-K and 10-Q text to dateLLM selectorlong, short or neutralLong-short optimizermean-variance weightsBacktestnet of all costsEvery data read takes an as-of date and fails if anything newer comes back.Every model call is written to a ledger, with its cost, before its result is used.

Figure 1. One month of the pipeline. The accent paths are the switch the thesis is built around: regime information into the selector, into the optimizer, both or neither.

The problem with the obvious test

The natural way to evaluate a stock picker is to run it over the last twenty years of filings. For a language model that test is broken before it starts. The model was trained on the internet, and the internet knows what happened to Apple in 2019. A backtest on dates before the model’s training cutoff measures memory as well as judgment, and nothing in the returns tells the two apart. Glasserman and Lin (2023) call this look-ahead bias and propose removing company identifiers from the text so the model cannot connect it to what it remembers.

Before writing a line of the selector, I ran two studies to find out how large the problem is for the models I intend to use. Both ran in the last week of October 2026.

Does the model remember?

The first study asks directly. Each model was given a ticker, a company name and a month, no evidence at all, and asked whether the stock beat the equal-weighted S&P 500 that month, with a probability. There were 1,400 stock-months: a hundred random members for each of seven months before both models’ documented training cutoffs and seven months after, with the two months around the cutoffs left out as a buffer. The same stock-months went to both models, and the answers were scored against CRSP and Compustat returns.

Opus 4.8
before
afterGPT-5.6 Sol
before
after
AUC of the stated probability0.640.520.740.49
Mean monthly rank IC0.250.030.460.03
Hit rate on the largest fifth of moves68.9%55.8%75.7%54.5%
Items the model says it remembers8.4%0.0%7.1%0.0%

Preliminary. One prompt, two runs, 1,400 stock-months over seven months each side of the cutoffs. Figures are the second run; the first agrees. Probe outputs are in the thesis repository and have not been reproduced by anyone else.

Before its cutoff, GPT-5.6 Sol separated winners from losers with a monthly rank information coefficient near 0.45, which a working quantitative strategy would be glad of. After its cutoff that falls to about zero, and its hit rate falls below what you get by always answering “below average”. Opus 4.8 remembers less, but the before-and-after gap in its hit rate has a confidence interval above zero in both runs. Memory also fades toward the cutoff: both models were sharpest on mid-2025 and weakest on the two months just before their cutoffs, which suggests older history is more exposed, not less.

The models were also asked whether they remembered each stock-month. They said yes for between 6 and 13 percent of items while their answers showed recall across the whole set. A prompt that asks a model to ignore what it knows cannot be relied on, because the model does not know what it knows.

Can masking fix it?

The second study tested the proposed defence. If the firm’s identifiers are removed from the text, the model should not be able to connect the filing to the ending. I built three masks of increasing severity and applied them to fifty excerpts of about five hundred tokens, drawn from the 2022 and 2023 filings of twenty large firms, two per sector where possible. The first mask removes the name, former names, ticker, exchange, executives, headquarters and dates, and rounds every dollar and share figure. The strict mask adds a lexicon built from the firm’s own filings, including every subsidiary named in Exhibit 21, every trademarked name and every term that only this firm uses in the corpus, and restates dollar amounts as shares of revenue. Masking an excerpt takes a few hundredths of a second and uses no model call, so it could have run over the whole universe.

It did not work. With the strict mask, Opus 5.5 named the firm in 48 of 50 excerpts and GPT-6.1-Sol in 45 of 50. Both named the sector in at least 47 of 50, and neither ever answered “cannot tell”. The strict mask removed about two thirds of the specific clues the models had cited and most of the surviving name slips, and identification barely moved. When the clues were read and classified, the largest group was not a leaked name or a telltale figure but the business profile itself: segment structure, product mix, the firm’s own vocabulary. That is also the content a stock selector needs. A mask strong enough to hide the firm would hide the evidence.

Preliminary. Fifty excerpts from twenty large firms, one prompt, one run per model and mask. The probe models are not the selector models.

What that decided

Identification is a sign of risk rather than a measure of harm. A model that can name the firm might not use what it remembers when it scores a stock, and a model that cannot name it might still be drawing on what it knows. No identification test can show that a masked pre-cutoff backtest is clean. It can only show that this one is not, and it did.

So the masked historical backtest is dropped. The thesis evaluates the selector only on months after each model’s documented training cutoff, which for the chosen models means March 2026 onward: seven complete months at the time of writing, growing by one each month. That is a short window and a real cost. I would rather report an honest result over seven months than an impressive one over twenty years.

The work is not wasted. The filing pipeline, the point-in-time stamps and the fixed-form summaries are used unchanged for the post-cutoff tests, where masking is not needed.

What is built, and what is next

The data layer pulls S&P 500 membership, returns and factors from CRSP and Compustat through WRDS, extends past the end of the CRSP file with Compustat so that the post-cutoff months exist at all, and records every extract in a manifest with its query, row count and checksum. Every reader takes an as-of date and raises if anything it returns is dated later, and the tests fail on leakage. The gateway routes every model call through one interface with a ledger, a cache keyed on the exact request and a per-call cost, so a run’s budget is known before it starts rather than after. The evidence pipeline downloads filings, extracts the risk-factor and management-discussion sections, stamps each with its acceptance time and builds packets to a token budget.

WRDS access came through on 29 October 2026. November is for the as-of tests, a factor baseline, a Python port of the Costa and Kwon model and a pilot of the selector, with a progress form at the end of the month. An interim report follows in mid-January. In February the protocols freeze and the official runs happen, one frozen protocol file per reported result.

What it does not claim

These are preliminary studies with the limits that implies. One prompt, one run per model, fifty passages, seven months on each side of a cutoff. The models probed for identification are not the models that will do the selecting, though all four cutoffs postdate every filing tested. The recall test names the firm outright, so it bounds leakage from above rather than measuring what a selector prompt would leak. None of it says anything yet about whether a language model can pick stocks. That is the question the rest of the year is for.

The thesis is mine, supervised by Prof. Roy H. Kwon. I wrote the code with Claude Code and Codex in the loop, under tests I set, and the decisions recorded above are mine. The two model families I build with are also the subjects of the leakage studies, which is a conflict I record rather than pretend away. The repository is private until the thesis is submitted.

← All work