Lesson 475 showed that the date printed on a report differs from the date its content became known, and section 4 of Lesson 305 showed how to check that gap with a data checklist. This lesson looks at the same problem again as an error in the order of calculation. In backtest code, look-ahead information usually hides in the order of a single line of calculation.
First we compute a hypothetical teaching moving-average rule on synthetic prices built to have no edge, in two different orders, and measure the gap. Next we look at look-ahead information hidden in full-period statistics. Last, with one public data series that is released late, we check how far apart the observation date and the availability date are.
1. Three times: decision, availability, execution
A rule has three times. The decision time is when the value used in the decision was fixed. The availability time is when that value could actually be seen. The execution time is when the order placed on that decision was filled.
For a rule that decides on the close, the decision time and the availability time are the same, right after the market close of period t. An order can only go out after that, so the decision must be attached only to the return of period t + 1. In this course this is called shifting by one period; the calculation that attaches the decision to the next period is written lag 1, and the one that attaches it to the same period's return is written lag 0.
Three numbers show why lag 0 is a problem. Assumptions: the close rose from 100 to 103 and moved above the moving average, so the rule switched to holding. The lag 0 calculation gives this decision that period's rise of (103 − 100) ÷ 100 × 100 = 3%. But that 3% is a move that had already finished before the decision was made.
2. A fake result made by one period
We measure the size with synthetic data made with a fixed seed. Prices over 1,260 periods (about five years if daily) were built from period returns with a mean of 0 and a standard deviation of 1%. Because the mean is 0 and today's return has nothing to do with tomorrow's, the data is built so that no rule can have an edge.
The rule is a hypothetical teaching rule: if the close is above the 20-period moving average, hold for the next period; otherwise cash. The cash return is assumed to be 0. The Sharpe ratio is computed from period returns with a risk-free rate of 0 and annualized by multiplying by the square root of 252 (Lesson 587 adds the interest rate).
The result of one path swings a lot with luck, so 50 paths, seeds 20261103 through 20261152, were fixed before writing and the same calculation was repeated on each. The first three value columns of the table below are medians of the values computed for each path, and the last column is the value for the first path (seed 20261103), drawn in figure 1.
| Calculation (synthetic data, 50 paths) | Median annual compound return | Median Sharpe ratio (annualized, 252 periods) | Median maximum drawdown | Sharpe ratio, first path |
|---|---|---|---|---|
| lag 1, shifted by one period | 0.0% | 0.06 | 23.3% | 0.63 |
| lag 0, with look-ahead information | 44.2% | 3.45 | 4.0% | 3.05 |
| Holding throughout | −2.5% | −0.07 | 34.0% | −0.15 |

Same data, same rule, only one line of order differs, yet the median annual compound return splits into 0.0% and 44.2%. The lag 0 calculation collects the return of periods when the close moved above the moving average, which are mostly periods when the price rose. It sidesteps, in cash, the return of periods when the close moved below, which are mostly periods when the price fell. It counts the move that caused the decision again as the result of the decision, so this number is not a property of the rule but an error in the order of calculation. The Sharpe ratio of lag 0 was between 3.03 and 3.96, and it was higher than lag 1 on all 50 paths.
Looking only at the first path, even the calculation shifted by one period seems fine. On this path the rule held for 46.3% of the periods and switched between holding and cash 110 times, with an annual compound return of 6.9% and a Sharpe ratio of 0.63. But across the 50 paths, the Sharpe ratio of lag 1 was between −0.72 and 1.05, with a median of 0.06. 0.63 is the 10th highest of the 50. The gap between 0.63 and the median of 0.06, on data with no edge, is the size of the luck that enters when only one path is shown.
3. Look-ahead information hidden in statistics: normalizing by the full-period mean
Even with the order shifted correctly, there is one more way for look-ahead information to enter. It is normalizing a signal by the mean, standard deviation or maximum of the full period. The full-period mean contains every price after the decision time.
On the same synthetic prices we computed a second hypothetical teaching rule: "if the close is below the mean, hold for the next period," with the mean taken in two ways. One is the mean of all 1,260 periods; the other is a cumulative mean that uses only the closes up to that period. Both are lag 1.
| Calculation (synthetic data, 50 paths) | Median annual compound return | Median Sharpe ratio (annualized) | Sharpe ratio, first path |
|---|---|---|---|
| Based on the full-period mean | 3.4% | 0.35 | 0.45 |
| Based on the cumulative mean up to then | 0.6% | 0.14 | 0.00 |

The full-period mean already contains the later part of the path. The more high prices a day has still ahead of it, the more likely it is to look below that mean, so the decision "below the mean" itself contains information from later prices. Figure 2 shows the account on the first path. Comparing path by path, the Sharpe ratio based on the full-period mean was higher in 44 of the 50 paths.
This error is smaller than lag 0, and it does not appear on every path. So it is hard to catch from the results alone; you find it by reading the code. If you need normalization, use only expanding or rolling windows computed from data up to that point.
4. Data released late: observation date and availability date
For data released with a delay, such as macroeconomic indicators, start by doubting the date printed in the table. We downloaded the Federal Reserve's industrial production index (INDPRO) by date from St. Louis Fed ALFRED. In the table, the June 2024 value is dated 2024-06-01.
The July 16, 2024 vintage has no June value, and its last observation is May at 103.1168. In the vintage of the next day, July 17, 2024, the June value of 103.9941 appears for the first time, and on the same day the May value was also revised to 103.3282. The June value became usable 46 days after the observation date, on 2024-07-17.
If this value is attached to June 1, 2024 or to the last trading day of June, the calculation decides about 3 to 7 weeks early with a number that had not yet been released. So for data released late, store a separate availability-date column next to the observation date, and have the rule attach data only through the availability-date column. If you could not confirm the release time, using the data from the next trading day is the conservative choice.
The values did not stay the same either. At the first release, June's change from the previous month was (103.9941 ÷ 103.3282 − 1) × 100 = about 0.64%. With the latest values from FRED, May is 100.8630 and June is 100.8940, so about 0.03%. These latest values were downloaded on November 2, 2026, US Eastern Time, and they are the same as the ALFRED vintage of November 2, 2026. The principle of downloading revised indicators by vintage and using the values visible on that day was covered in Lesson 223 and Lesson 227, so here we only point to it.
| Column to store | Example: industrial production, June 2024 |
|---|---|
| Observation date | 2024-06-01 |
| Value (first release) | 103.9941 |
| Availability date | 2024-07-17 |
| Vintage date | 2024-07-17 |
5. Code checklist
Errors in the order of calculation are found in the code, not in the results table. Before handing over backtest code, check the following.
- When the decision column is attached to the return column, is it shifted by one period? Is there no negative shift that pulls later rows forward?
- Does the formula that makes the decision for period t read no rows from t + 1 or later?
- When normalizing by a mean, standard deviation, maximum or minimum, does it use only the window up to that point, not the full period?
- Is monthly or quarterly data attached to its availability date, not to the month end or the observation date? Were revised indicators downloaded by vintage?
- Did you run lag 0 and lag 1 side by side? If the two differ very much, the rule leans heavily on the move just before the decision, so also check the fill assumptions (Lesson 586).
The record for this lesson is the timing box of the plan. For each data series, write the decision, availability and execution times, the rule that sets the availability date, and the results of running lag 0 and lag 1 together.
Try it yourself
- From the results table in section 2, read the gap in median annual compound return and the gap in median Sharpe ratio between lag 0 and lag 1. What is the one thing that differs between the two calculations?
- Using the 50-seed results, write in one sentence why the first path's lag 1 Sharpe ratio of 0.63 cannot be called "this rule's result."
- Set the availability date of each item. (a) The industrial production index for June 2024. (b) Assumptions: the quarterly revenue of a company whose fiscal quarter ends on March 31 and whose results were released after the market close on April 25. (c) Assumptions: a monthly indicator for October released before the market open on November 14.
- Assumptions: the closes from period 1 are 100, 103, 101, 104. The close of period 2 set holding, and the close of period 3 set cash. Find the return that the holding decision of period 2 receives under lag 0 and under lag 1.
Answers
First, the median annual compound returns are 44.2% and 0.0%, a gap of 44.2 percentage points, and the median Sharpe ratios are 3.45 and 0.06, a gap of 3.39. The data and the rule are the same; the only difference is whether the decision was attached to the same period's return or to the next period's return.
Second, because on data built to have no edge, the same rule's Sharpe ratio scattered from −0.72 to 1.05 across paths, with a median of 0.06. 0.63 is just one result from the upper part of that scatter.
Third, (a) is July 17, 2024, confirmed with the ALFRED vintages. (b) can be known only after the market close on April 25, so the decision comes after the April 25 close and the return is attached from the next trading day. Attaching it to March 31 would use information 25 days early. (c) can be known before the market open on November 14, so it can be used from the decision on that day's close. Attaching it to October 31 would use information 2 weeks early.
Fourth, the return of period 2 is (103 − 100) ÷ 100 × 100 = 3%, and the return of period 3 is (101 − 103) ÷ 103 × 100 = about −1.94%. Lag 0 gives the holding decision of period 2 the 3% that caused the decision, and lag 1 gives it the next period's about −1.94%. The cash decision of period 3 gets 0% either way. It is the same decision, but only lag 0 collected a rise that had already finished.
Data: synthetic data made by Havilah Research with a fixed seed. Seed 20261103, 1,260 periods, period returns with mean 0 and standard deviation 1%. The tables in sections 2 and 3 are medians over 50 paths with seeds fixed in advance, 50 seeds from 20261103 to 20261152, and the figures show the first path. The release delay and revisions were checked with the industrial production index INDPRO (Federal Reserve G.17) from St. Louis Fed FRED and ALFRED: the vintages of July 16 and July 17, 2024, and the latest values (downloaded on November 2, 2026, US Eastern Time, equal to the vintage of November 2, 2026).
Related lessons
- Lesson 223. Reading vintage data with ALFRED: real-time periods, first releases and latest values
- Lesson 227. The unemployment rate and the Sahm rule: real-time versus after-the-fact values
- Lesson 475. What happens if you use information you could not have known at the time?
- Lesson 305. Testable trading rules and data checks
- Lesson 243. Reading trends with highs and lows
