AI in the investment process: a tool inside a process, not the process
On this page
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).
| Step | What a model does there | Handbook |
|---|---|---|
| Data | reads text and satellite images into numbers | chapter 10 |
| Forecast | ranks stocks by their expected return | chapter 1 |
| Construction | recommends which construction method suits the current market | chapter 10 |
| Risk limits | checks every day that country and sector exposures are inside their limits | chapter 11 |
| Execution | forecasts short-term price and volume to speed up or slow down an order | chapter 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
where is feature of ticker on day , standardised, and 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.
| Measure | Value |
|---|---|
| Months the top pick beat the average of the five tickers | 28 of 56 (50%) |
| Months each ticker was the top pick | NVDA 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 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.
| Process | Average month | Worst month | Largest fall | Growth |
|---|---|---|---|---|
| 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 and fell on the way. Process C grew , and its largest fall, , was no worse than SPY’s. B grew less than C and fell further, . A’s worst month, from 4 April 2022, was all in NVDA and lost ; B lost 13.9% that month and C, which had already switched the model off, lost SPY’s 6.1%.
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).
| Feature | Coefficient |
|---|---|
| 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
| People think | Actually |
|---|---|
| A good backtest means the model has skill | process A grew 611.7% with picks that beat the average half the time |
| The model’s forecast is the decision | construction, limits and execution decide what is held, and can shrink or veto it |
| A person signing off is oversight | only if the person can question the model; Samuel makes a manager explain a deviation from its ranking |
| An explainable model is a correct model | the coefficients explained the model clearly, and what they showed was a bet on one stock |
| Limits and monitoring fix a bad model | they cap what it can cost; C still held the model’s picks in 38 of 56 months |
| Rules cover every case | only 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:
| Variable | Holds |
|---|---|
X | the seven features, one row per day and ticker |
y | each row’s return over the next 21 trading days, the answer the model learns |
months | the days the model is refitted and the portfolio rebalanced, every 21 trading days |
F, R | the forecasts and the real 21-day returns, one row per month, one column per ticker |
pick, beat | the top pick each month, and whether it beat the average of the five |
W | the 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
| Idea | What it says | On the five tickers |
|---|---|---|
| A chain, not a box | a forecast becomes money only through construction, limits and execution | one forecast, three processes, growth from +255.2% to +611.7% |
| Decision support | the model advises, a person decides and must explain a deviation | Samuel in chapter 11 |
| Low signal-to-noise | most of a return is noise, so a forecast is weak evidence | top pick beat the average in 28 of 56 months |
| Explanation as a smell test | read what the model learned before trusting it | largest coefficient on volatility: a bet on NVDA |
| Limits and monitoring | cap what a wrong forecast can cost, take the model out when its record goes bad | largest 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.