Module 10 · Financial Time-Series Foundations Lesson 100 of 120

Look-Ahead Leakage and Time-Aware Data Splits

Blocking late information even when its event date is old.

2:30 clip5:19:09–5:21:39 in the full courseWatch on YouTube

Transcript

20 sentences · select one to jump there

Check your understanding

Why is record B excluded even though its event time is two?

Choose one answer

Code lab

Run it yourself

The lesson source in 7 languages. Edit it, run TypeScript and Python right here, and compare with the expected output.

100-look-ahead-leakage-and-time-aware-data-splits.ts
Start from GitHub
/**
 * Fintech Math Bootcamp · Lesson 100 of 120
 * Look-Ahead Leakage and Time-Aware Data Splits
 * Module 10: Financial Time-Series Foundations
 *
 * Scenario: Blocking late information even when its event date is old
 * Rule:     eligible feature: eventTime≤cutoff AND availableTime≤cutoff
 *
 * Try it:   Why is record B excluded even though its event time is two?
 *
 * Lesson article: https://thefintechbuilder.com/financial-mathematics-statistics-and-data-foundations/financial-time-series-foundations/look-ahead-leakage-and-time-aware-data-splits/
 * Free course:    https://courses.thefintechbuilder.com
 * Synthetic teaching example, not financial advice or a production library.
 */

export function lesson100() {
  const rows=[{id:"A",event:1,available:1,value:10},
   {id:"B",event:2,available:4,value:20},
   {id:"C",event:3,available:3,value:30}];
  const cutoff=2;
  const result=rows.filter(r=>r.event<=cutoff && r.available<=cutoff).map(r=>r.id);
  return result;
}

export const checkedResult = ["A"];

// Run this file directly: npx tsx lessons/10-financial-time-series-foundations/100-look-ahead-leakage-and-time-aware-data-splits.ts
if (process.argv[1] && import.meta.url.endsWith(process.argv[1].replace(/\\/g, "/").split("/").pop()!)) {
  console.log(JSON.stringify(lesson100(), null, 2));
}

Your output

Press Run to execute the code in your browser.

Expected output

[
  "A"
]

Prefer your own machine? Every file is in the course repository · open it in Codespaces.

Lesson notes

The rule

eligible feature: eventTime≤cutoff AND availableTime≤cutoff