NEW+--
Move Left Complete list

How to Unleash the Potential of Multiple ML Models in Trading?

Machine Learning models have come a long way from being algorithms which worked in isolation. Now you can combine various ML models together as well.

What is the advantage of using different ML models together?

Certain ML models excel in volatile, trending markets, while others are proficient in stable, range-bound markets. By combining these models, you gain the ability to trade in all market types.

Thus, you could combine both models and be able to create a trading strategy which works during the mean reverting stage of Tesla during September 2020 and November 2020, as well as during the trending stage from December 2020 to January 2021.

Now, you can add up multiple similar ML models, like grouping decision trees together to create a Random Forest model. 

Or, you can shake things up and add multiple different ML models.

How do you add multiple different ML models?

Voting Classifier model to the rescue! In fact, you can see the cumulative returns from the Individual machine learning models and the voting classifier model below. 

 

You can see the voting classifier model has outperformed the individual machine learning models. It is important to note that backtesting results do not guarantee future performance. The presented strategy results are intended solely for educational purposes and should not be interpreted as investment advice. A comprehensive evaluation of the strategy across multiple parameters is necessary to assess its effectiveness. Let’s see how the voting classifier model is used.

 

All the concepts covered in this topic are taken from section 13 unit 6 of the Quantra course on Machine Learning for Options Trading. You can preview the concepts taught in this course by clicking on the free preview button.

 

Note: The links in this tutorial will be accessible only after logging into quantra.quantinsti.com and enrolling for the free preview of the course.


 

 

 



 

In trading, machine learning models can be used for different purposes, predicting the next day’s movement being one of them. It would be great if the model could tell us whether the price will move up or down the next day. You can use decision trees for the same purpose. However, decision trees have an issue of overfitting. This means they are good on trained data but sometimes are not good when working on unseen or out-of-sample data. To solve this issue, the random forest classifier model is an ensemble model which gives only part of the train data to multiple decision trees. And then predict the output. 

Here, the random forest model takes the output of all decision trees, and based on majority voting, gives the final output. For example, assume that two decision trees give the output as 1, implying that the price will go up tomorrow, and only 1 decision tree, gives the output as 0, implying that the price will not go up tomorrow. Then, by majority voting, the random forest model will give the output as 1.

But we are only using one type of ML model here, which is the decision tree. 

You can use the voting classifier model to combine different types of ML models.

Instead of using a single type of ML model, which is decision trees, you can use XGBoost, logistic regression, and SVM models, which will be trained on the train data.

Once the models are trained, you will pass the test data to the models.

The models will predict the output and the voting classifier will aggregate the outputs.

Here, you can see that the XGboost model predicted 1, whereas logistic regression and SVM models predicted 0. The voting classifier will choose the class which was predicted a majority number of times. 

This means that the voting classifier model will predict 0. 

This is called hard voting, where you only consider the number of times a particular class is predicted.

 

Is there another method of voting which is used by the voting classifier model?

Yes. It is called soft voting. Let’s see this in detail.

In soft voting, the voting classifier model checks the probability of occurrence of all possible classes.

For example, the voting classifier receives the probability of occurrences of all three models, for class 0, as shown below.

You can see that the XGBoost model predicted the probability of occurrence of 0 as 0.2, or 20%. 

The voting classifier will take the average of these values, which is 0.47 in this case.

The voting classifier will then receive the probability of occurrences of all three models, for class 1, as shown below.

 

The voting classifier will now take the average of these values, which is 0.53. 

You can see that the average for class 1 is higher. 

Thus, the voting classifier will give the final output as 1.

 

Is there a difference between the performance of your strategy using either of the two voting methods?

Well, let’s use the predicted signals to buy or sell the asset. In this Quantra Classroom, we have used the OHLC data of the SPDR S&P 500 ETF (Ticker: SPY) for generating features and training and testing the various models. When the model predicts 1, it means that we will go long on the asset the next day. If the model predicts 0, we will take no position or sell any existing long position the next day. Based on the strategy returns, you will plot the cumulative returns of the strategy.

You can see that the cumulative returns from using the soft voting classifier are better than the hard voting classifier model.

 

 

It is important to note that backtesting results do not guarantee future performance. The presented strategy results are intended solely for educational purposes and should not be interpreted as investment advice. A comprehensive evaluation of the strategy across multiple parameters is necessary to assess its effectiveness. So what do you think, do you want to combine multiple ML models as well?

The Python code for the voting classifier model can be found in this unit of the Machine Learning for Options Trading course.

You need to take a Free Preview of the course by clicking on the green-coloured Free Preview button on the right corner of the screen next to the FAQs tab and go to Section 13 and Unit 11 of the course.

 


 

What to do next? 

  • Go to this course 
  • Click on
  • Run the codes in the course

Drop us your comments and queries on the community

 

 


 

IMPORTANT DISCLAIMER: This email is for educational purposes only and is not a solicitation or recommendation to buy or sell any securities. Investing in financial markets involves risks and you should seek the advice of a licensed financial advisor before making any investment decisions. Your investment decisions are solely your responsibility. The information provided is based on publicly available data and our own analysis, and we do not guarantee its accuracy or completeness. By no means is this communication sent as the licensed equity analysts or financial advisors and it should not be construed as professional advice or a recommendation to buy or sell any securities or any other kind of asset.

RELATED KEYWORDS