A model for a trading strategy is typically designed to predict the side of the trade (go long or go short), while predicting the side correctly is obviously important, it is also important to predict the size of the position. For example, when a model predicts to go long with a 51% probability, it makes intuitive sense to open a smaller position, than when the model predicts to go long with an 80% probability. The estimation of the size of the position is also called metalabeling. The primary model focuses on predicting the side, while the metalabeling model focuses on predicting the size. Stacking these two models can be helpful when trying to increase the performance of the trading strategy.
When building a binary classifier (e.g. go long or go short), the classifier presents a trade-off between type-I errors (false positives) and type-II errors (false negatives). This can also be represented with a confusion matrix which categorises the predictions into true positives, false negatives, false positives, and true negatives. It is desirable to maximise the number of true positives and false negatives and minimise the number of false positives and true negatives.
Confusion Matrix
Predicted: True
Predicted: False
Actual: True
True Positives
True Negatives
Actual: False
False Positives
False Negatives
From this confusion matrix, several metrics can be computed to assess the performance of the model.
accuracy=TP+FNTP+FP+TN+FNprecision=TPFP+TPrecall=TPTP+FNF1=2recall1+precision1accuracy = \dfrac{TP +FN}{TP+FP+TN+FN} \\ precision = \dfrac{TP}{FP + TP} \\ recall = \dfrac{TP}{TP + FN} \\ F_1 = \dfrac{2}{recall^{-1} + precision^{-1}} \\
Metalabeling is particularly useful when the goal is to achieve a higher F1 score. First, a primary model is built which predicts the side of the trade (go long or short). For the primary model, it is sufficient to achieve a high recall, it is not needed to achieve high precision in this stage. To increase the precision of the model, we use the metalabeling model to filter out the false positives generated by the primary model. This can be achieved by taking the predictions of the primary model and label which ones are predicted wrong or correct, to generate these so-called metalabels. Using the existing features (potentially other features as well) combined with the metalabels we fit the metalabel model.
When the primary model makes a prediction, this prediction is assessed by the metalabeling model. If the metalabeling models predicts true, then the position is created, however if the metalabeling predicts false, then no position is taken and nothing is done.
This however a binary approach, while it is also possible to estimate the size of the position given the predicted probability of the metalabeling model. This is discussed in the next part.
Last modified 6mo ago
Copy link