I am curious about how people retrain successful models.
Currently I train from backtest and then test my models on a forward walk on new data, while I am testing those models, new data is generated and it presents the opportunity to train another model on the trade data of the last model and then run model(A), and have its ouput+input confirmed by model(B) by layering the models one after the other to confirm each other's signals, or I could train a new model from the combined data, or both.
I have built into my methods to constantly serialise my normalised data class so now I am wondering which direction tends to be the best in real world trading.
Hopefully I am clearly explains myself, I am curious what other people do.
Mia Alissi
In QuantConnect, you can retrain your models periodically as your algorithm executes. This can be done by calling the
Train
method as a Scheduled Event in theInitialize
method. This allows you to train a new model based on the latest data, which can be useful in real-world trading where market conditions can change over time.Here is an example of how you can schedule your model to be retrained every Sunday at 8:00 AM:
This method can be used with various machine learning libraries supported by QuantConnect, such as Stable Baselines, Aesera, GPlearn, Hmmlearn, Scikit-Learn, Tslearn, and XGBoost.
As for the best approach between layering models to confirm each other's signals, training a new model from the combined data, or both, it can depend on various factors such as the specific trading strategy, the type of data, and the market conditions. It might be beneficial to experiment with different approaches and see which one works best for your specific use case.
You can find more information about training models in QuantConnect in the documentation.
Please note that the effectiveness of these methods can vary and should be thoroughly tested before deploying in a live trading environment.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
AgedVagabond
Sorry, my question isn't how to train models, it's how to properly layer models, model(a) is trained by signal(a), model(b) is trained on only the trades taken by model(a) using signal(a)+model(a) confirming a valid signal using new data that neither model has seen before.
I guess my question is, does it work out better to train new model from the already filtered data or run models in layers and progressively build up layers over time as the algo runs.
It's probably a stupid question, layering seems obvious and testing will probably give me an answer but testing is only testing, experience is worth a lot more.
Mia Alissi
The approach of layering models, where one model's output is used as input for another model, is a common technique in machine learning known as ensemble learning. However, the effectiveness of this approach can vary greatly depending on the specific models and data used.
In the context of trading, using one model to filter trades for another model could potentially improve the performance of your algorithm by reducing the number of false positives. However, it could also lead to overfitting if the models become too complex or too closely tailored to the historical data.
As for whether it's better to train a new model from the already filtered data or to layer models, it can depend on various factors such as the specific trading strategy, the type of data, and the market conditions. It might be beneficial to experiment with both approaches and see which one works best for your specific use case.
In QuantConnect, you can implement this layered approach by using multiple Alpha Models in your algorithm. For example, you could use one Alpha Model to generate initial trade signals, and then use another Alpha Model to filter these signals based on additional criteria. You can determine which Alpha Model's Insights to take inside the Portfolio Construction Model by checking the class of where the Insight came from using
Insight.SourceModel
.Unfortunately, the provided extracts do not contain specific code examples for layering models in this way. However, you can find more information about using multiple Alpha Models in the QuantConnect documentation.
Please note that the effectiveness of these methods can vary and should be thoroughly tested before deploying in a live trading environment.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
AgedVagabond
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!