AI in the investment process: a tool inside a process, not the process

On this page
  1. A forecast is one step in a chain
  2. Who decides: decision support or an autonomous decision
  3. One model, three processes, on the five tickers
  4. The explanation is the smell test
  5. Limits and monitoring are where the judgment goes
  6. Check yourself
  7. Traps
  8. The code
  9. Summary
  10. References

Train a model to forecast next month’s return for five tickers, buy whichever it likes best, and the backtestTesting a trading strategy by simulating how it would have traded over some past period. can look like a discovery. On the blog’s prices from 2021 to 2025, that is exactly what happens below: a plain linear regressionA simple method that predicts a numeric answer by assuming a straight-line relationship between the inputs and the answer., refitted every month, turns 10,000 dollars into 71,000. Then look closer. Its favourite beat the average of the five in half the months, which is what a coin would do, and on the way the money fell by more than half. A forecast like that is not yet a decision. It still has to go through the steps the earlier posts in this series walked: portfolio construction, frictions and capacity and execution. This post is about where machine learning sits among those steps, who gets the final say, and what happens to one model’s forecasts when they go through three different processes.

The main source is the CFA Institute Research Foundation’s Handbook of Artificial Intelligence and Big Data Applications in Investments, edited by Larry Cao: chapter 1 for the pitfalls of machine learning in finance, chapters 8 and 10 for where models are used, and chapter 11 for a system built to advise a human team rather than replace it.

A forecast is one step in a chain

An investment process is the chain of steps that turns information into positions and then checks them: data comes in, research turns it into a forecast, construction turns forecasts into weights, risk checks hold the weights inside limits, execution trades them, and monitoring watches what happened. A model can work at any step, and the Handbook has examples of most of them (Table 1).

adjust or

switch off

Data

prices, filings,

news, images

Forecast

a number

per asset

Construction

forecasts

to weights

Risk limits

caps, checks,

approval

Execution

weights

to trades

Monitoring

is it still

working?

Table 1. Where a model can work in the chain, with an example from the Handbook
StepWhat a model does thereHandbook
Datareads text and satellite images into numberschapter 10
Forecastranks stocks by their expected returnchapter 1
Constructionrecommends which construction method suits the current marketchapter 10
Risk limitschecks every day that country and sector exposures are inside their limitschapter 11
Executionforecasts short-term price and volume to speed up or slow down an orderchapter 8

The forecast is one box out of six. Chapter 8 opens with the same point: “A central task in implementing any trading strategy is executing the trades required to reach a desired portfolio position.” A forecast earns nothing until the other steps turn it into a position, and each of those steps can change, shrink or veto it. Chapter 1 names one way the later steps undo an early one, the implementation gapPositions a backtest holds that could not, or could not sensibly, be traded live, such as tiny stocks or shares that cannot be borrowed.: positions “in the backtest that are either impossible or infeasible to trade in live production”, such as small stocks that cost too much to trade or shares that cannot be borrowed to sell short.

Who decides: decision support or an autonomous decision

A model used for decision support gives a person a recommendation and the person decides. A model that makes an autonomous decision acts on its own output, and nobody looks before the money moves. Most of the Handbook’s examples are the first kind. Its preamble calls the CFA Institute’s position “AI + HI (human intelligence)”, and the foreword argues that current AI is better suited to “areas of success enjoyed by human-operated models or, at least, AI models with close human supervision”, because markets change in ways the training dataThe observed examples a method learns from: they are used to teach it how to make its estimate. never showed.

Chapter 11 describes one such system in detail. Samuel, built by the real estate team at APG Asset Management, “acts as a digital colleague that guides the human investment team with transparent, systematized, and well-substantiated advice”. It is built mostly from written rules (what the chapter calls symbolic AIAI built from human-readable representations of a problem, such as written rules and decision trees, rather than learned from large amounts of data.) rather than learned from data, and the way it is wired into the team is the useful part:

  • It proposes, a person disposes. While a portfolio manager builds a cash-flow model, Samuel suggests default values, and “the human PM can decide whether to overwrite the assumption or stick with Samuel’s assumption”.
  • Disagreeing has a cost. Samuel ranks a proposed trade against the alternatives. “If other actions are more favorable, the portfolio managers that do the proposal will have to explain why they deviate from Samuel.”
  • It does the repetitive checking. It “can check every day whether the aggregated investment exposure to a country or sector exceeds the limits”, work a person does less consistently.
  • The person covers what the rules never saw. Samuel’s principles “were formed in the past (by humans) and might not yet have been adjusted to a new reality, such as in March 2020 when COVID-19 was affecting the world”. The chapter says it “likely cannot operate on its own”.

Who holds the final say is a design decision, written into the process before the model is switched on. Even a system built entirely from language models keeps the same shape. In TradingAgents, a research framework of AI agents that copies a trading firm, analyst agents gather information, a trader agent proposes, risk-team agents check the proposal (“Risk guardians assess the decision against current market conditions to mitigate risks”), and a fund manager agent “approves and executes the trade” (Figure 1 of the paper).

One model, three processes, on the five tickers

To see what the process does to a forecast, the script below builds one model and runs its forecasts through three processes. The model is a linear regression that forecasts each ticker’s return over the next 21 trading days (about a month) from the seven price featuresAn input variable a model uses to make its prediction; also called a predictor or an independent variable. the machine learning posts use: the last 1-, 5- and 20-day returns, the volatilityHow much an asset's price spikes and dips; most often measured as the standard deviation of its per-period returns. over 5 and 20 days, the price against its 20-day average, and its position in the Bollinger bandsBands above and below a moving average, set by the standard deviation, that widen when volatility rises and narrow when it falls.. Every feature is first standardisedRescale data so that each column has a mean of zero and a variance of one. (minus its average, divided by its standard deviationThe square root of the variance, a measure of spread in the same units as the data.), so each coefficientOne of the unknown constants of a model, such as the intercept or the slope, that fitting estimates from training data. reads as “the forecast change for a one standard deviation move in that feature”:

ŷ, the forecast return of ticker i over the 21 days after day t

y^i,t=b0+∑k=17bk zk,i,t\key{\hat{y}_{i,t}} = b_0 + \sum_{k=1}^{7} b_k \, z_{k,i,t}

where zk,i,tz_{k,i,t} is feature kk of ticker ii on day tt, standardised, and b0,…,b7b_0, \ldots, b_7 are the coefficients fitted by least squaresThe standard way to fit a line: choose the intercept and slope that make the residual sum of squares as small as possible.. Every 21 trading days from January 2021 the model is refitted on every earlier row whose answer was already known that day. A row’s answer is its next 21 days of return, so the newest 21 days are left out of training; chapter 1 recommends this kind of “sufficient gap period” against leakageInformation that would not be available at prediction time being used to build a model, which makes its performance estimates overly optimistic., training on information the model would not have had live. That gives 56 months of forecasts, from January 2021 to September 2025.

The same forecasts then go through three processes. Every trade pays 0.1% of the value traded.

  • A, the model is the process. All the money goes into the ticker with the highest forecast.
  • B, the model is one input. The top pick gets at most 40%, and the other 60% stays in SPY, the benchmarkThe yardstick a strategy's returns are compared against, usually the market index that the traded securities belong to..
  • C, as B, with monitoring. After each month the script records whether the model’s pick beat the average of the five tickers. If it lagged in 4 or more of the last 6 finished months, the model is switched off and everything sits in SPY until its record improves.
Table 2. The model’s forecasts on their own, 56 months from January 2021
MeasureValue
Months the top pick beat the average of the five tickers28 of 56 (50%)
Months each ticker was the top pickNVDA 43, XOM 8, GLD 2, GS 2, SPY 1
Average correlation of forecasts with real returns, across the five tickers+0.070

Table 2 is the model on its own. Its favourite beat the average in exactly 50%\key{50\%} of months, and the correlationCovariance rescaled into a measure that always lies between minus one and one. between what it forecast and what happened is close to zero. Chapter 1 says to expect this: “Financial data have a low signal-to-noise ratioHow much of what is measured is useful information against random variation. In returns it is low: any one fact explains little.”, because a return squeezes company news, the economy, investor behaviour and positioning into one number.

Table 3. Monthly returns of each process, 56 months from January 2021, after 0.1% costs
ProcessAverage monthWorst monthLargest fallGrowth
SPY alone+1.23%−7.5%−20.6%+88.2%
NVDA alone+6.07%−29.0%−59.0%+1,254.6%
A. All in the model’s top pick+4.66%−25.7%−57.4%+611.7%
B. Top pick capped at 40%, rest in SPY+2.60%−13.9%−34.2%+255.2%
C. As B, switched off when the picks keep lagging+2.60%−13.9%−20.6%+274.1%

The largest fall is the biggest drop from the highest value reached so far to a later low, at month ends (also called the maximum drawdownThe largest fall in a portfolio's value from its highest point to the lowest point that comes after it.). Table 3 and Figure 1 show the trade a process makes. Process A grew 611.7%\good{611.7\%} and fell 57.4%\bad{57.4\%} on the way. Process C grew 274.1%\good{274.1\%}, and its largest fall, 20.6%\bad{20.6\%}, was no worse than SPY’s. B grew less than C and fell further, 34.2%\bad{34.2\%}. A’s worst month, from 4 April 2022, was all in NVDA and lost 25.7%\bad{25.7\%}; B lost 13.9% that month and C, which had already switched the model off, lost SPY’s 6.1%.

{"panels":[{"x0":47.96,"x1":565.2,"y0":29.16,"y1":261.28,"title":"The same forecasts through three processes (log scale)","xlabel":"Month held (its first day)","ylabel":"Value of 10,000 dollars at its end (dollars)","xlog":false}],"series":[{"panel":0,"label":"SPY alone","color":"var(--chart-grey, #a3a19c)","kind":"line","x":["2021-01-04","2021-02-03","2021-03-05","2021-04-06","2021-05-05","2021-06-04","2021-07-06","2021-08-04","2021-09-02","2021-10-04","2021-11-02","2021-12-02","2022-01-03","2022-02-02","2022-03-04","2022-04-04","2022-05-04","2022-06-03","2022-07-06","2022-08-04","2022-09-02","2022-10-04","2022-11-02","2022-12-02","2023-01-04","2023-02-03","2023-03-07","2023-04-05","2023-05-05","2023-06-06","2023-07-07","2023-08-07","2023-09-06","2023-10-05","2023-11-03","2023-12-05","2024-01-05","2024-02-06","2024-03-07","2024-04-08","2024-05-07","2024-06-06","2024-07-09","2024-08-07","2024-09-06","2024-10-07","2024-11-05","2024-12-05","2025-01-07","2025-02-07","2025-03-11","2025-04-09","2025-05-09","2025-06-10","2025-07-11","2025-08-11"],"y":[10344.1,10392.3,11037.6,11299.4,11485.5,11804.8,11969.7,12357.2,11725.2,12635.1,12512.0,13113.4,12554.5,11863.3,12578.4,11814.5,11304.6,10598.7,11453.8,10847.3,10495.6,10409.6,11299.3,10705.4,11502.9,11110.1,11413.8,11554.6,11985.9,12326.1,12667.9,12541.7,11973.3,12260.7,12878.7,13251.5,13989.5,14579.4,14735.8,14690.9,15188.6,15840.6,14781.6,15400.0,16231.7,16486.1,17342.6,16883.8,17232.0,15945.6,15783.5,16235.8,17350.3,17994.3,18349.2,18819.2],"sx":[71.47,79.87,88.27,97.22,105.34,113.74,122.69,130.81,138.93,147.88,156.0,164.4,173.35,181.75,190.15,198.82,207.22,215.62,224.85,232.97,241.09,250.04,258.16,266.56,275.79,284.19,293.15,301.26,309.66,318.62,327.29,335.97,344.37,352.48,360.6,369.56,378.23,387.19,395.59,404.54,412.66,421.06,430.29,438.41,446.81,455.48,463.6,472.0,481.23,489.91,498.87,506.98,515.38,524.34,533.01,541.69],"sy":[233.28,232.93,228.45,226.7,225.48,223.44,222.41,220.03,223.94,218.38,219.11,215.61,218.85,223.07,218.71,223.38,226.67,231.47,225.69,229.74,232.2,232.81,226.7,230.72,225.37,227.96,225.95,225.04,222.31,220.22,218.18,218.93,222.38,220.62,216.95,214.83,210.79,207.71,206.92,207.15,204.67,201.53,206.69,203.64,199.72,198.56,194.79,196.78,195.26,201.04,201.8,199.7,194.75,192.04,190.58,188.7]},{"panel":0,"label":"NVDA alone","color":"var(--chart-amber, #c0781a)","kind":"line","x":["2021-01-04","2021-02-03","2021-03-05","2021-04-06","2021-05-05","2021-06-04","2021-07-06","2021-08-04","2021-09-02","2021-10-04","2021-11-02","2021-12-02","2022-01-03","2022-02-02","2022-03-04","2022-04-04","2022-05-04","2022-06-03","2022-07-06","2022-08-04","2022-09-02","2022-10-04","2022-11-02","2022-12-02","2023-01-04","2023-02-03","2023-03-07","2023-04-05","2023-05-05","2023-06-06","2023-07-07","2023-08-07","2023-09-06","2023-10-05","2023-11-03","2023-12-05","2024-01-05","2024-02-06","2024-03-07","2024-04-08","2024-05-07","2024-06-06","2024-07-09","2024-08-07","2024-09-06","2024-10-07","2024-11-05","2024-12-05","2025-01-07","2025-02-07","2025-03-11","2025-04-09","2025-05-09","2025-06-10","2025-07-11","2025-08-11"],"y":[10308.0,9493.56,10563.8,11018.8,13396.3,15777.9,15454.3,17074.8,15043.8,20128.3,24496.0,22967.2,19247.0,17491.7,20865.5,15507.3,14276.4,11541.0,14657.0,10409.8,10046.7,10086.3,12880.0,11256.7,16103.8,17776.7,20519.4,21892.7,29506.2,32447.6,34672.3,35930.3,34118.5,34360.6,35555.5,37488.0,52091.7,70760.8,66533.6,69145.8,92392.5,100328.0,75532.6,78526.1,97541.6,106851.0,110792.0,107034.0,99167.6,83067.3,87329.5,89101.7,109962.0,125981.0,139074.0,135461.0],"sx":[71.47,79.87,88.27,97.22,105.34,113.74,122.69,130.81,138.93,147.88,156.0,164.4,173.35,181.75,190.15,198.82,207.22,215.62,224.85,232.97,241.09,250.04,258.16,266.56,275.79,284.19,293.15,301.26,309.66,318.62,327.29,335.97,344.37,352.48,360.6,369.56,378.23,387.19,395.59,404.54,412.66,421.06,430.29,438.41,446.81,455.48,463.6,472.0,481.23,489.91,498.87,506.98,515.38,524.34,533.01,541.69],"sy":[233.54,239.67,231.71,228.57,214.02,201.83,203.37,195.95,205.38,183.69,169.06,173.86,187.03,194.15,181.01,203.12,209.28,225.12,207.32,232.81,235.45,235.16,216.95,226.98,200.31,192.94,182.26,177.43,155.2,148.12,143.18,140.53,144.38,143.85,141.31,137.36,112.86,90.04,94.63,91.76,70.17,64.03,85.18,82.29,66.13,59.34,56.64,59.21,64.9,78.1,74.37,72.87,57.2,47.07,39.71,41.67]},{"panel":0,"label":"A. All in the model's top pick","color":"var(--chart-maroon, #b6262c)","kind":"line","x":["2021-01-04","2021-02-03","2021-03-05","2021-04-06","2021-05-05","2021-06-04","2021-07-06","2021-08-04","2021-09-02","2021-10-04","2021-11-02","2021-12-02","2022-01-03","2022-02-02","2022-03-04","2022-04-04","2022-05-04","2022-06-03","2022-07-06","2022-08-04","2022-09-02","2022-10-04","2022-11-02","2022-12-02","2023-01-04","2023-02-03","2023-03-07","2023-04-05","2023-05-05","2023-06-06","2023-07-07","2023-08-07","2023-09-06","2023-10-05","2023-11-03","2023-12-05","2024-01-05","2024-02-06","2024-03-07","2024-04-08","2024-05-07","2024-06-06","2024-07-09","2024-08-07","2024-09-06","2024-10-07","2024-11-05","2024-12-05","2025-01-07","2025-02-07","2025-03-11","2025-04-09","2025-05-09","2025-06-10","2025-07-11","2025-08-11"],"y":[9415.22,12284.2,13644.5,14232.2,17303.1,17246.0,17452.5,19203.0,17333.6,18169.6,17408.1,16286.9,13648.8,12404.0,14796.5,10996.8,10123.9,8184.13,8552.0,9467.01,9117.84,9153.84,11689.2,10216.0,14615.0,16133.2,18622.4,17262.3,23231.1,25547.0,27298.5,28289.0,26862.5,27053.1,27993.9,29515.4,41013.3,55712.1,52383.9,54440.5,72743.3,78991.4,59469.0,61825.9,76797.4,84127.2,87229.9,84271.3,78077.5,65401.3,68757.1,70152.4,69982.3,80037.0,73220.5,71171.8],"sx":[71.47,79.87,88.27,97.22,105.34,113.74,122.69,130.81,138.93,147.88,156.0,164.4,173.35,181.75,190.15,198.82,207.22,215.62,224.85,232.97,241.09,250.04,258.16,266.56,275.79,284.19,293.15,301.26,309.66,318.62,327.29,335.97,344.37,352.48,360.6,369.56,378.23,387.19,395.59,404.54,412.66,421.06,430.29,438.41,446.81,455.48,463.6,472.0,481.23,489.91,498.87,506.98,515.38,524.34,533.01,541.69],"sy":[240.29,220.47,212.65,209.51,194.96,195.2,194.32,187.2,194.82,191.32,194.51,199.46,212.63,219.75,206.61,228.72,234.88,250.73,247.45,239.88,242.68,242.39,224.17,234.21,207.53,200.17,189.48,195.13,173.01,165.93,160.99,158.34,162.19,161.67,159.12,155.18,130.67,107.85,112.44,109.57,87.98,81.85,102.99,100.1,83.94,77.15,74.46,77.03,82.71,95.91,92.18,90.69,90.87,80.87,87.5,89.61]},{"panel":0,"label":"B. Top pick capped at 40%, rest in SPY","color":"var(--chart-blue, #3b6ea5)","kind":"line","x":["2021-01-04","2021-02-03","2021-03-05","2021-04-06","2021-05-05","2021-06-04","2021-07-06","2021-08-04","2021-09-02","2021-10-04","2021-11-02","2021-12-02","2022-01-03","2022-02-02","2022-03-04","2022-04-04","2022-05-04","2022-06-03","2022-07-06","2022-08-04","2022-09-02","2022-10-04","2022-11-02","2022-12-02","2023-01-04","2023-02-03","2023-03-07","2023-04-05","2023-05-05","2023-06-06","2023-07-07","2023-08-07","2023-09-06","2023-10-05","2023-11-03","2023-12-05","2024-01-05","2024-02-06","2024-03-07","2024-04-08","2024-05-07","2024-06-06","2024-07-09","2024-08-07","2024-09-06","2024-10-07","2024-11-05","2024-12-05","2025-01-07","2025-02-07","2025-03-11","2025-04-09","2025-05-09","2025-06-10","2025-07-11","2025-08-11"],"y":[9972.57,11216.0,12130.6,12512.2,13715.8,13926.5,14109.9,14950.1,13909.2,14825.1,14489.9,14534.5,13221.1,12302.1,13696.1,11790.3,11110.6,9842.77,10496.2,10612.0,10249.0,10214.7,11870.2,10897.4,13261.5,13540.9,14598.6,14280.3,16575.1,17518.3,18290.2,18446.3,17572.7,17875.6,18664.9,19394.9,23065.1,26955.2,26484.5,26852.1,31008.9,32873.0,28304.6,29463.8,33272.5,34855.7,36456.3,35383.1,34780.7,30964.1,31410.8,32205.7,33501.0,36172.4,35368.1,35515.9],"sx":[71.47,79.87,88.27,97.22,105.34,113.74,122.69,130.81,138.93,147.88,156.0,164.4,173.35,181.75,190.15,198.82,207.22,215.62,224.85,232.97,241.09,250.04,258.16,266.56,275.79,284.19,293.15,301.26,309.66,318.62,327.29,335.97,344.37,352.48,360.6,369.56,378.23,387.19,395.59,404.54,412.66,421.06,430.29,438.41,446.81,455.48,463.6,472.0,481.23,489.91,498.87,506.98,515.38,524.34,533.01,541.69],"sy":[236.0,227.25,221.41,219.1,212.26,211.13,210.15,205.84,211.22,206.47,208.17,207.94,215.0,220.37,212.37,223.53,227.95,236.98,232.19,231.38,233.97,234.22,223.03,229.4,214.77,213.22,207.62,209.26,198.16,194.04,190.82,190.19,193.8,192.53,189.31,186.46,173.54,161.94,163.25,162.22,151.5,147.15,158.3,155.31,146.25,142.79,139.44,141.67,142.95,151.61,150.54,148.68,145.74,140.03,141.7,141.39]},{"panel":0,"label":"C. As B, switched off when the picks keep lagging","color":"var(--chart-purple, #7c5fd3)","kind":"line","x":["2021-01-04","2021-02-03","2021-03-05","2021-04-06","2021-05-05","2021-06-04","2021-07-06","2021-08-04","2021-09-02","2021-10-04","2021-11-02","2021-12-02","2022-01-03","2022-02-02","2022-03-04","2022-04-04","2022-05-04","2022-06-03","2022-07-06","2022-08-04","2022-09-02","2022-10-04","2022-11-02","2022-12-02","2023-01-04","2023-02-03","2023-03-07","2023-04-05","2023-05-05","2023-06-06","2023-07-07","2023-08-07","2023-09-06","2023-10-05","2023-11-03","2023-12-05","2024-01-05","2024-02-06","2024-03-07","2024-04-08","2024-05-07","2024-06-06","2024-07-09","2024-08-07","2024-09-06","2024-10-07","2024-11-05","2024-12-05","2025-01-07","2025-02-07","2025-03-11","2025-04-09","2025-05-09","2025-06-10","2025-07-11","2025-08-11"],"y":[9972.57,11216.0,12130.6,12512.2,13715.8,13926.5,14109.9,14950.1,13909.2,14825.1,14489.9,15174.9,14528.1,13728.3,14555.7,13671.8,13081.7,12264.9,13254.4,12552.5,12145.6,12046.0,13075.5,12388.2,13311.2,13580.9,14641.8,14322.5,16624.1,17570.1,18344.3,18500.9,17624.6,17928.5,18720.1,19452.2,23133.3,27034.9,26562.8,26931.4,31100.6,32970.2,28388.3,29550.9,33370.8,34958.7,36564.1,35487.7,34883.5,31055.6,31503.6,32300.9,34492.5,35772.7,36478.2,37412.7],"sx":[71.47,79.87,88.27,97.22,105.34,113.74,122.69,130.81,138.93,147.88,156.0,164.4,173.35,181.75,190.15,198.82,207.22,215.62,224.85,232.97,241.09,250.04,258.16,266.56,275.79,284.19,293.15,301.26,309.66,318.62,327.29,335.97,344.37,352.48,360.6,369.56,378.23,387.19,395.59,404.54,412.66,421.06,430.29,438.41,446.81,455.48,463.6,472.0,481.23,489.91,498.87,506.98,515.38,524.34,533.01,541.69],"sy":[236.0,227.25,221.41,219.1,212.26,211.13,210.15,205.84,211.22,206.47,208.17,204.73,207.98,212.2,207.84,212.5,215.79,220.59,214.81,218.86,221.32,221.93,215.82,219.85,214.49,213.0,207.4,209.04,197.94,193.82,190.6,189.97,193.58,192.31,189.09,186.24,173.33,161.72,163.03,162.0,151.28,146.93,158.08,155.09,146.03,142.57,139.22,141.45,142.73,151.39,150.32,148.46,143.57,140.85,139.4,137.51]}]} 2026-11-27T02:53:37.636917 image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/ 2021 2022 2023 2024 2025 Month held (its first day) 1 0 4 1 0 5 Value of 10,000 dollars at its end (dollars) The same forecasts through three processes (log scale) SPY alone NVDA alone A. All in the model's top pick B. Top pick capped at 40%, rest in SPY C. As B, switched off when the picks keep lagging
Figure 1. The same forecasts through three processes, 2021 to 2025

These are 56 months on five tickers, one of which rose more than twelvefold. The cap of 40% and the “4 of the last 6” rule were set once, as round numbers, and not tuned; the aside below shows what two other settings of the rule do.

The switch-off rule with other settings

Switching the model off when its picks lagged in 3 of the last 6 months turns it off for 25 months, with growth of +238.4% and a largest fall of −20.6%. Requiring 5 of 6 turns it off for 10 months, with growth of +240.2% and a largest fall of −27.2%. With 4 of 6, as in Table 3, it is off for 18 months, 12 of them in 2022. None of the three falls further than B’s −34.2%.

The explanation is the smell test

Process A’s growth looks like skill, and Table 2 says the model’s picks were a coin flip. The coefficients explain the gap. A linear model gives its explanation for free, because the forecast is just the sum of the coefficients times the features (Table 4).

Table 4. Coefficients of the last fit, August 2025 (% over 21 days, per one standard deviation of the feature)
FeatureCoefficient
Last day’s return−0.09
Last 5 days’ return+0.21
Last 20 days’ return+0.32
Volatility over 5 days+0.63
Volatility over 20 days+1.33
Price against its 20-day average−0.54
Position in the Bollinger bands+0.15

In the last fit the largest coefficient is on the 20-day volatility: the model learned “the more a ticker has been swinging, the more it will return”. In 44 of the 56 months its top pick was also the most volatile of the five tickers, and in 2021 to 2025 that mostly meant NVDA, the top pick 43 times. So process A was close to “hold NVDA”, with a few detours, and it did worse than simply holding NVDA (Table 3). The model had found one stock’s run, and its coefficients say so in plain numbers.

Chapter 1 calls this the smell testChecking whether the relationships a model found between its inputs and its forecasts make intuitive or economic sense.: checking whether the relationships a model found between its inputs and its forecasts “make intuitive or economic sense”. Its example uses SHAP valuesA way to explain a model: each feature's average contribution to the forecast, found by comparing results with and without that feature. (a method that splits each forecast into a contribution from every feature) on a model of financial distress, and says that if a relationship ran the wrong way (more distance from default forecasting more distress), “it is likely that the ML algorithm made a mistake, possibly through overfittingWhen a flexible model follows the noise in its training data too closely, so its predictions on new data are poor.”. Here the test is a question a person would ask in a review: is “buy the most volatile ticker” an idea to put money behind, or a description of one stock in one five-year window? Chapter 1 also notes why somebody asks: “with billions of investment dollars on the line, asset owners demand managers that use ML-based algorithms explain how the investment decisions are made”. Chapter 10 calls the model validation step, where model and data are made understandable to people again, “a step often forgotten or underrated”.

The process decides how much a forecast may cost when it is wrong. The cap and the switch-off rule did not make the model smarter. They limited how much one forecast could move, and they took the model out of the decision when its record went bad, which in this period meant 2022.

Limits and monitoring are where the judgment goes

The two rules in B and C are small versions of the controls the Handbook describes. The 40% cap is a position limit, the same kind of check Samuel runs daily on country and sector exposure. The switch-off rule is model monitoring: watching a model’s live record and reducing its say when the record goes bad. It is the mechanical version of the person in chapter 11 who knows “when old principles are not applicable anymore given that the circumstances have changed”.

Neither rule fixes a bad model. Over the whole period both rules cost return: C ended at +274.1% against A’s +611.7%. What they buy is a loss the owner can survive and a reason for every position that a person can read. The Handbook’s foreword puts the same trade as a choice between two plans: one with a 70% success rate based on fundamentals “that can be readily understood”, and one with 80% that “is a black box or cannot be easily understood”. It expects most rational investors to take the first.

A rule only covers what its designers thought of. Chapter 11 expects “edge cases in which the systematic way of thinking does not translate well. These cases must be recognized by humans.” The switch-off rule in C reacts after months of bad picks; it cannot stop a single bad month that comes out of nowhere. C’s own worst month, from 9 July 2024, lost 13.9% while the model was switched on.

Check yourself

The model's top pick beat the average of the five tickers in only 28 of 56 months, yet process A grew 611.7%. Where did the growth come from?

From NVDA. The model’s largest coefficient is on 20-day volatility, so its pick was the most volatile ticker in 44 of the 56 months, and NVDA in 43. NVDA rose more than twelvefold over the period, so a mostly-NVDA portfolio grew too, while the picks were no better than a coin at beating the average. Holding NVDA alone did better, +1,254.6%.

Process C gave up most of A's growth. What did it buy with it?

A survivable loss. A’s largest fall was −57.4% and its worst month −25.7%; C’s largest fall was −20.6%, the same as SPY’s. C was switched off for 18 months, 12 of them in 2022, and in A’s worst month, from 4 April 2022, it held SPY and lost 6.1%.

Why is the model retrained only on rows at least 21 trading days old?

Each row’s answer is the return over the next 21 trading days, so a row newer than that does not have its answer yet on the day the model is fitted. Training on it would use information the model could not have had live, which is leakage. Chapter 1 recommends a gap period between training and testing for this reason.

Traps

Table 5. Common mistakes when a model enters an investment process
People thinkActually
A good backtest means the model has skillprocess A grew 611.7% with picks that beat the average half the time
The model’s forecast is the decisionconstruction, limits and execution decide what is held, and can shrink or veto it
A person signing off is oversightonly if the person can question the model; Samuel makes a manager explain a deviation from its ranking
An explainable model is a correct modelthe coefficients explained the model clearly, and what they showed was a bet on one stock
Limits and monitoring fix a bad modelthey cap what it can cost; C still held the model’s picks in 38 of 56 months
Rules cover every caseonly the ones their designers foresaw; chapter 11 leaves edge cases to people

The code

The snippet rebuilds the seven features from the price file, refits the model every 21 trading days, runs the three processes and prints the worst month, largest fall and growth in Table 3. Variables:

Table 6. What the snippet’s variables hold
VariableHolds
Xthe seven features, one row per day and ticker
yeach row’s return over the next 21 trading days, the answer the model learns
monthsthe days the model is refitted and the portfolio rebalanced, every 21 trading days
F, Rthe forecasts and the real 21-day returns, one row per month, one column per ticker
pick, beatthe top pick each month, and whether it beat the average of the five
Wthe weights of processes A, B and C, one row per month
import numpy as np
import pandas as pd

url = "https://raw.githubusercontent.com/ankurtrapasiya/examples/main/data/prices.csv"
px = pd.read_csv(url, index_col="date", parse_dates=True)
r = px.pct_change()
sma = px.rolling(20).mean()
feats = {                                     # each is a table: one row per day, one column per ticker
    "ret_1d": r, "ret_5d": px / px.shift(5) - 1, "ret_20d": px / px.shift(20) - 1,
    "vol_5d": r.rolling(5).std(), "vol_20d": r.rolling(20).std(),
    "sma_ratio": px / sma - 1, "bollinger": (px - sma) / (2 * px.rolling(20).std()),
}
X = pd.concat(feats, axis=1).stack(future_stack=True)        # rows (date, ticker), one column per feature
y = (px.shift(-21) / px - 1).stack(future_stack=True)        # return over the next 21 days
ok = X.notna().all(axis=1) & y.notna()
X, y = X[ok], y[ok]

days = X.index.get_level_values(0).unique()
months = days[days >= "2021-01-01"][::21]
months = months[months <= days[-22]]
fore, real = [], []
for d in months:
    train = X.index.get_level_values(0) < days[days.get_loc(d) - 21]   # answers known on day d
    mu, sd = X[train].mean(), X[train].std()
    A = np.column_stack([np.ones(train.sum()), (X[train] - mu) / sd])
    beta = np.linalg.lstsq(A, y[train].to_numpy(), rcond=None)[0]
    fore.append(beta[0] + (X.loc[d] - mu) / sd @ beta[1:])
    real.append(y.loc[d])
F, R = pd.DataFrame(fore, index=months), pd.DataFrame(real, index=months)
pick = F.idxmax(axis=1)
beat = np.array([R.loc[d, pick[d]] > R.loc[d].mean() for d in months])

W = {"A": pd.DataFrame(0.0, index=months, columns=R.columns)}
W["B"], W["C"] = W["A"].copy(), W["A"].copy()
for i, d in enumerate(months):
    W["A"].loc[d, pick[d]] = 1.0                        # A: the model is the process
    W["B"].loc[d, "SPY"] = 0.6                          # B: the pick gets 40%, SPY the rest
    W["B"].loc[d, pick[d]] += 0.4
    lagging = i >= 6 and (~beat[i - 6:i]).sum() >= 4    # C: picks lagged in 4 of the last 6 months?
    W["C"].loc[d, "SPY"] = 1.0 if lagging else 0.6
    if not lagging:
        W["C"].loc[d, pick[d]] += 0.4

print(f"top pick beat the average in {beat.sum()} of {len(months)} months; picks: {pick.value_counts().to_dict()}")
for name, w in [("SPY", None), *W.items()]:
    if w is None:
        w = pd.DataFrame(0.0, index=months, columns=R.columns); w["SPY"] = 1.0
    traded = w.diff().abs().sum(axis=1)
    traded.iloc[0] = 1.0
    ret = (w * R).sum(axis=1) - 0.001 * traded           # 0.1% of the value traded
    g = (1 + ret).cumprod()
    fall = (g / g.cummax().clip(lower=1) - 1).min()
    print(f"{name}: worst month {ret.min():+.1%}, largest fall {fall:+.1%}, growth {g.iloc[-1] - 1:+.1%}")

It prints that the top pick beat the average in 28 of 56 months, with NVDA picked 43 times, then one line per process: SPY −7.5%, −20.6%, +88.2%; A −25.7%, −57.4%, +611.7%; B −13.9%, −34.2%, +255.2%; C −13.9%, −20.6%, +274.1%. stack turns a table with one column per ticker into one row per (date, ticker) pair, and np.linalg.lstsq solves the least-squares fit, the job LinearRegression().fit does in scikit-learn.

The script behind the real numbers

The tables and the chart come from examples/ai-in-the-investment-process/model_inside_process.py, which runs on the blog’s five tickers. To run it yourself, clone the examples repo: its README has a three-command Docker setup, or run uv run ai-in-the-investment-process/model_inside_process.py.

Summary

Table 7. The ideas, one line each
IdeaWhat it saysOn the five tickers
A chain, not a boxa forecast becomes money only through construction, limits and executionone forecast, three processes, growth from +255.2% to +611.7%
Decision supportthe model advises, a person decides and must explain a deviationSamuel in chapter 11
Low signal-to-noisemost of a return is noise, so a forecast is weak evidencetop pick beat the average in 28 of 56 months
Explanation as a smell testread what the model learned before trusting itlargest coefficient on volatility: a bet on NVDA
Limits and monitoringcap what a wrong forecast can cost, take the model out when its record goes badlargest fall −57.4% for A, −20.6% for C

References

  • Larry Cao (ed.), Handbook of Artificial Intelligence and Big Data Applications in Investments (CFA Institute Research Foundation, 2023). Used by chapter:
    • Preamble (“AI + HI”) and the foreword by Susan Spinner (close human supervision; the Plan A and Plan B example).
    • Chapter 1, Mike Chen and Weili Zhou, “On Machine Learning Applications in Investments”: the section on the signal-to-noise ratio, and “How to Avoid Common Pitfalls” for overfitting, the smell test with SHAP values, the gap period against leakage, the implementation gap, and the demand for explanations.
    • Chapter 8, Peer Nagy, James Powrie and Stefan Zohren, “Machine Learning for Microstructure Data-Driven Execution Algorithms”: the introduction, on execution reaching a desired position and forecasts that speed up or slow down an order.
    • Chapter 10, Jochen Papenbrock, “Accelerated AI and Use Cases in Investment Management”: text and satellite data, the model validation step, and the recommender for a portfolio construction method.
    • Chapter 11, Huib Vaessen, “Symbolic AI: A Case Study”: Samuel, its parts, how portfolio managers interact with it, its daily limit checks, and the human edge over it.
  • Yijia Xiao, Edward Sun, Di Luo and Wei Wang, TradingAgents: Multi-Agents LLM Financial Trading Framework (arXiv, 2024, version 7 of 2025). Figure 1 and section 3 for the roles, from analyst agents to the risk team and the fund manager who approves the trade.
Tagged finance, machine-learning, risk← Home