Hi, what is the best way to manage orders from multiple alpha models that are independent? Problem: different alphas sending variable number of orders. How do you folks efficiently track these orders down? Basically, how do you manage a portfolio of alphas?
Thank you,
Mia Alissi
To manage orders from multiple independent alpha models, you can use the CompositeAlphaModel. This model combines multiple alpha models into a single alpha model and properly sets each insight's 'SourceModel' property. This allows you to track which alpha model generated the insight.
Here is an example of how you can use it:
You can also use the
InsightCollection
andPortfolioTargetCollection
helper classes to manage collections ofInsight
andPortfolioTarget
respectively. These collections can be used in every Portfolio Construction Model and Execution Model.Here is an example of how you can use these collections:
You can also implement a custom Portfolio Construction Model (PCM) that consumes multiple alphas. In this model, you can implement an InsightCollection and decide what to do with the active insights based on the source of the insight.
Here is an example of how you can use the
GetActiveInsights
method in your PCM:For more information, you can refer to the following sources:
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.
Vytautas Zukauskas
Source model is really okay, I can return insight with the source model simply by writing “insight.SourceModel = ”Model name" inside alpha model and then I can access it easily in portfolio model.The problem I have is accessing the quantity of a position, that a given alpha model has opened.Example:
On one signal Model A bought 5 SPY's; Model B bought 7 SPY's. On another signal Model A bought 4 SPY's; Model B bought 9 SPY's. Rule is- each alpha can have a max of 15 SPY's and I need to enforce that, I suppose, in portfolio construction model. Is there a way to access the current position that a given alpha currently has?
I think I could do some counter inside the alpha model itself, on self. Wonder if there is a fancier way of doing so
Mia Alissi
To enforce a maximum quantity of a specific security for each alpha model, you could create a custom Portfolio Construction Model (PCM). In this PCM, you could keep track of the quantity of each security that each alpha model has opened.
Here's a rough idea of how you could implement this:
In this example,
self.alpha_positions
is a dictionary that keeps track of the quantity of each security that each alpha model has opened. TheCreateTargets
method checks if the alpha model has reached the maximum quantity for the security before creating a target for the insight.Please note that this is a simplified example and you might need to adjust it according to your specific needs. For example, you might need to handle the case where an insight has a flat direction, which means that the alpha model wants to close the position for the security.
For more information, you can refer to the following sources:
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.
Vytautas Zukauskas
Mia, could you give please an example of a more complex portfolio construction model which can handle flat positions too? Additionally, there should not be anything with magnitude.
The portfolio model should accept SourceModel; quantity; security
Then it should keep track of the quantity each model has for each security
Thank you
Mia Alissi
Based on the information provided, you can create a custom Portfolio Construction Model (PCM) that keeps track of the quantity of each security that each alpha model has opened. Here's a Python example of how you could implement this:
In this example,
self.alpha_positions
is a dictionary that keeps track of the quantity of each security that each alpha model has opened. TheCreateTargets
method checks if the alpha model has reached the maximum quantity for the security before creating a target for the insight.Please note that this is a simplified example and you might need to adjust it according to your specific needs. For example, you might need to handle the case where an insight has a flat direction, which means that the alpha model wants to close the position for the security.
For more information, you can refer to the following sources:
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.
Jared Broad
Vytautas Zukauskas Alphas emit signals, not classical positions. If you're interested in a track record of alpha signals, it would be the alpha's responsibility to record it.
I'd be wary of using alpha insights as a proxy for positions or trying to manage positions with them. It is the PCM and Execution model's responsibility to handle that work.
You may find it easier to use the classic design of QCAlgorithm as it gives you a lot more control.
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.
Vytautas Zukauskas
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!