# Advances in Financial Machine Learning – Ch3: Labelling

Hi,

let´s go on with chapter 3 of Advances in Financial Machine Learning. The last chapter was about creating features for machine learning, i.e. bars in this case. Chapter 3 on the other hand is about labelling, which is necessary for supervised learning algorithms.

Fixed-Time Horizon Method: This method is probably the most common method of labelling financial data. Here, an observation is assigned a value int {-1,0,1} based on the return (r) in a specific time frame. For example, the observation will be labelled -1 if r < -theta (with theta being a specific threshold value), 0 if r <= theta, and  1 if r > theta. De Prado, however, mentions multiple reasons to avoid this method:

1. As seen in chapter 2 already, time bars do NOT exhibit desiderable statistical properties.
2. It does not make sense to apply the same threshold value theta disregarding other factors such as for example realized or implied volatility in the markets.

To solve these issues, some fixes are:

1. Labelling with a varying threshold value. This may be achieved with an rolling exponentially weighted standard deviation of the returns, for example.
2. As seen in the previous chapter, dollar and volume bars exhibit better statistical properties. Use these bars instead.

However, even adjusting for these flaws leaves out a crucial aspect that has to be considered: the path followed by prices. It is not realistic at all that the path would not be considered. It is not about if a profit is to be realized at some point. Rather, it is of utmost importance to label if one was stopped out earlier.

The Triple-Barrier Method: A labelling method proposed by De Prado that takes the path of the prizes into account is the triple-barrier method. This method labels a given observation according to the first barrier that was touched. There are three barriers in this method. Two horizontal barriers relate to profit-taking and the stop-loss. As introduced above, these two barriers are dynamic functions of volatility. Further, there is a vertical barrier which is related to a deadline or a time-stop. If the upper (Profit-taking) barrier is hit first, the observation is labelled 1. If the lower (stop-loss) barrier is hit first, the observation is labelled -1. Finally, if the vertical barrier (time-stop) is hit first, the label is either 0 or the return r.

The chart below shows the tripple-barrier method in action with the upper horizontal barrier being the profit target, the lower horizontal barrier being the stop-loss point, the left vertical barrier being the starting point of the bar and the right vertical barrier being the time-stop. In this case, neither profit-taking nor loss-taking is triggered and instead the time-stop is hit. Side & Size of a Bet: ML algorithms can help us (i.e. learn) the side and the size of bets too. For instance, we would like to learn the side of a bet when a model to choose the side is not available. In this case it is impossible to distinguish between profit-taking and a stop-loss in the model. Consequently, the horizontal barriers will be non-existent or symmetrical.

Meta-Labelling: If the side of the trade is known, we still need to find the appropriate size of the trade. After all, trade sizing is a crucially defining factor. Here, meta-labelling enters the story. When meta-labelling is active, we know the side of a trade. Therefore, we may distinguish between profit-taking and loss-taking and the horizontal barriers do not have to be symmetric. The ML algorithm will be trained to decide whether or not to take a specific trade (0 or 1). Then, the probability of the prediction may be used in the sizing decision.

Such binary classification problems  represent a trade-off between type-I (False Positives) and type-II (False Negatives) errors. Evaluation metrics for these kinds of errors are Precision (True Positives/(True Positives+False Positives)), Recall (True Positives/(True Positives + False Negatives)), Accuracy ((True Positives + True Negatives)/(True Positives + True Negatives + False Positives + False Negatives)), and the F1-score (measuring efficiency of the classifier as average of Precision and Recall). Meta-labelling is a good approach to obtain a meaningfully high F1-score. Here, as a first step, a model with high recall is built and then meta-labelling is applied to correct for the low precision. As De Prado states “The role of the secondary ML algorithm [Meta-labelling] is to determine whether a positive from the primary (exogenous) model is true or false. [] Its purpose is to determine whether we should act or pass on the opportunity that has been presented. “

Further, four main advantages of Meta-labelling are:

1. It may be a substitute to fundamental analysis leading to the quandamental way of investing.
2. Because the ML algorithm does not decide the side but only the size of the bet, overfitting is limited.
3. Because decisions regarding size and side are separated, “sophisticated strategy structures” are possible. This relates to different strategies on the short and long side.
4. As De Prado states “achieving high accuracy on small bets and low accuracy on large bets will ruin you.” Therefore, the ML algorithm of meta-labelling focusing on this sizing aspect is truly crucial.

Communicating these concepts in words is rather difficult. As for chapter 2, applications and solutions to the exercises will be available later on my github page:

https://github.com/Herrsosa/Advances_F_ML

Best,

Nils