Basic Prerequisites: Probability & Measure Theory and Python/pandas. Fluency with Pillar 1 - Quantitative Research helps but is not required. (these are the folder-level prerequisites for pages 02–06; page 01 states its own, smaller, entry requirements)
1. Intuition & Practical Objective
Financial machine learning fails for two reasons long before the model is at fault: the features are not stationary enough and the labels are not what the strategy actually does. The first is a feature-engineering problem; the second is a labeling problem. Both are decisions made before any model is fit, and both silently cap the achievable Sharpe.
The standard textbook recipe - “predict the return over the next bars” - is wrong in a specific, measurable way. A trader does not hold blindly for bars: they take profit, cut losses, and time out. The Triple-Barrier Method (López de Prado, 2018) labels each observation by which barrier the price path touches first, which is exactly what the P&L of the strategy would have been. And because price levels are non-stationary while returns throw away all memory, Fractional Differentiation finds the minimal that passes a stationarity test while keeping as much of the price’s long memory as possible.
This folder is the topic-hub for feature engineering & target labeling in Kwant-Atlas. It (a) gives the fast formula/decision lookup below - job #1 of a hub - and (b) routes you to six sub-pages that walk from raw intuition through feature construction, target labeling, the triple-barrier/meta-labeling machinery, the failure modes, and the advanced tooling.
The one-sentence essence. “Label the observation by the first barrier the path touches (not by a fixed-horizon sign), separate direction from bet size with meta-labeling, and difference prices just enough to be stationary without erasing memory - because in finance the target and the features are modelling decisions, not data.”
2. Mathematical Ground Truth & Derivations
Quick-Reference Lookup (job #1). Notation: price, raw feature series, log-return, an ex-ante (point-in-time) volatility estimate, the vertical-barrier horizon (bars), the upper/lower barrier multipliers, the event start / first-barrier-touch times, the number of labels concurrent at , the backshift operator. All formulas below were re-executed and reproduced numerically (see §3).
| Quantity | Formula | Verified check |
|---|---|---|
| Fixed-horizon label (the naive target) | disagrees with triple-barrier on 19.7% of paths (0.5σ barriers) | |
| Dynamic barrier width | with from EWMA/realized vol through only | mean EWMA target |
| Triple-barrier label | +1:660 / −1:790 on dense events | |
| First-barrier touch time | path-dependent - needs the whole -path | |
| Meta-label (LdP §3.6) | , =primary side | precision 0.517 → 0.721 after filtering |
| Concurrency | max in the hub’s run ( under page 05’s ) | |
| Average uniqueness | effective of (3.6×) | |
| Fractional weights | ||
| Fixed-width window (FFD) | drop once $ | w_k |
| Min differencing order | here; memory corr at vs at | |
| Sample weight | time-decay attribution | used to debias non-IID draws |
Critical caveat (López de Prado §3.4, §19.6). The barriers must use an ex-ante volatility estimate (available at ). Using a full-sample or forward-looking injects the future into the label - see 05 · Failure Modes. Likewise, the right-hand side of every feature row must be computable from data ; the label may look forward (that is its job), the features may not.
3. Computational Implementation - the labeling engine
This runs on the standard library only and reproduces the verified numbers above: the fractional-differentiation order search with a Dickey–Fuller statistic, the triple-barrier labels, and the concurrency/average-uniqueness computation.
Read the output as the folder’s two punchlines in numbers: the price level needs only differencing to become stationary (not , which destroys memory), and the 1,450 overlapping triple-barrier labels behave like only 407.6 independent outcomes - the IID assumption overstates the sample by 3.6×.
4. Failure Modes & First-Principles Breakdowns
Hub signposts - the folder’s failure-mode analysis lives in 05 · Failure Modes & Practice. In one line each:
- Look-ahead in labeling - barriers computed from a future-wide or full-sample encode information the model cannot legally have at entry.
- Label overlap / non-IID draws - overlapping event windows make consecutive labels share returns, so naive -fold CV leaks and the effective sample is far smaller than the raw count.
- Over-differencing - returns are stationary but memoryless; integer differencing (and detrending) removes the cointegrating, slow-moving alpha that the features were supposed to carry.
- Target leakage through features - any feature row built with data (centred z-scores, future normalization, revised fundamentals) is a controlled experiment in fooling yourself.
- Class imbalance & rare labels - triple-barrier labels can be heavily skewed; accuracy is a misleading metric and rare classes should sometimes be dropped entirely (LdP §3.9).
5. References
- López de Prado, Marcos: Advances in Financial Machine Learning (Wiley, 2018)
- Hastie, Tibshirani & Friedman: The Elements of Statistical Learning (2nd ed., 2009)
- Tsay, Ruey S.: Analysis of Financial Time Series (3rd ed., 2010)
- Hosking, J.R.M. (1981): Fractional differencing, Biometrika 68(1)
- Gu, Kelly & Xiu (2020): Empirical Asset Pricing via Machine Learning, RFS 33(5)
6. Connected Graph Bridges
- Foundational base: Probability & Measure Theory · stationarity & unit-root testing
- Sibling topics: Backtesting Hygiene (triple-barrier labels set the purge/embargo width) · Stat-Arb & Pairs · Fundamental Multi-Factor Models
- Cross-pillar: Tree-Based Factor Ranking & Purged CV (consumes these labels) · Financial ML Pitfalls & Low SNR
- Sub-pages (in-folder): 01 From Zero · 02 Feature Construction · 03 Target Labeling · 04 Triple-Barrier & Meta-Labeling · 05 Failure Modes · 06 Advanced Extensions