Skip to main content

Quant Analytics: from scratch to pro · Machine learning in finance · Intermediate

Features and labels: fixed horizons and the triple barrier

A model is only as good as the question put to it. Features are what is known at the decision time; labels are the outcomes to learn. A fixed-horizon label ignores the path, the triple-barrier label follows it, and overlapping labels shrink the real sample size.

3 min read Reviewed Revision 1

In this lesson

  • Build features that use only information available at the decision time
  • Label an outcome with a fixed horizon and with the triple-barrier method
  • Set barrier widths from volatility
  • Compute the effective sample size when labels overlap

Read first: Machine learning for market data: what it can and cannot do, Volatility: from daily moves to an annual figure

Worked numbers

Each result is recomputed from the formula shown.

WhatFormulaResult
daily volatility0.0121.2%
upper barrier100 * (1 + 2 * sigma_d)102.40
lower barrier100 * (1 - 2 * sigma_d)97.60
barrier width2 * sigma_d2.4%
10-day volatilitysigma_d * sqrt(10)3.79%
return at the time limit99.0 / 100 - 11.0%
overlap between neighbouring 10-day labels9 / 1090%
effective sample size2500 / 10250

Check yourself

Entry at 100, daily volatility 1.2%, barriers at 2 daily volatilities. Where are the upper and lower barriers?

Upper: 100 x (1 + 2 x 0.012) = 102.40. Lower: 100 x (1 - 2 x 0.012) = 97.60.

The price touches 102.6 on day 3 and closes at 99.0 on day 10 (the time limit). What are the two labels?

Triple barrier: +1, the upper barrier was hit first, on day 3. Fixed 10-day horizon: the return is -1.0%, so the label is negative. The two labels disagree on the same path.

Why are barrier widths set from volatility and not as a fixed percentage?

A fixed 2.4% barrier is a large move in a quiet period and a small one in a turbulent period, so it would be hit at very different rates. Scaling by volatility keeps the question comparable across time.

Daily samples carry 10-day labels. With 2,500 samples, about how many independent labels are there?

About 2,500 / 10 = 250. Neighbouring labels share 9 of their 10 days, so they are 90% overlapped.

A feature uses the day's closing price, and the label starts from the same close. What is the risk?

If the decision would be made before the close, the feature uses information that was not available. The label must start after the last data point used by the features.

Key terms

Triple-barrier methodMachine learningData leakageVolatility

Sources

Informational content. Not investment advice.