Day 212 — The triple barrier labels what a trade would have done

Saturday, 6 March 2027 · Week 31 of 52 · Machine learning · Study day · 60 min

It replaces a fixed-horizon return with the outcome of an actual position with a stop and a target, which makes the label match the thing you would have experienced.

What you should be able to do tonight

  • Implement triple-barrier labelling with barriers set from a volatility estimate rather than from fixed percentages.
  • Report the label distribution and say what it tells you about the barrier widths you chose.

Tasks 60 min

35 min Implement it in qlib/ml/labels.py: for each observation, walk forward until the price crosses an upper barrier, a lower barrier, or the time limit, and record which. Set the barriers as multiples of the forecast volatility so they scale with the regime rather than being fixed percentages.

25 min Check the labels before modelling on them: report the fraction hitting each barrier. If almost everything hits the time limit the barriers are too wide to matter, and if almost nothing does they are too tight and you are labelling noise. Tune the multiples so all three outcomes are populated, and log that this tuning is itself a specification choice.

The running strategy

qlib/ml/labels.py implements volatility-scaled triple-barrier labelling with the outcome distribution reported, so the label reflects what a position with a stop and a target would have experienced.

Resources

Deliverable

qlib/ml/labels.py with triple-barrier labelling and the outcome distribution reported across three barrier settings.

Checkpoint

What does the triple barrier method label, and what problem with fixed-horizon labels does it solve?

Prepare for tomorrow

Ten minutes tonight so Day 213, Sunday, 7 March 2027 starts clean. This is what the evening email sends you.

For each triple-barrier label, count how many other labels overlap its time window.

Plot the distribution of that count.

That number has a name and it is tomorrow’s subject.