LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
Let's say I am running two alphas on the same symbol (e.g. #1 scalping and #2 trend following).
What if I want to run two different risk management models, each tied to their individual alpha model (e.g. #1 tight take-profit&stop-loss and #2 more relaxed risk parameters)?
How can I ensure that a particular risk management model is acting only on trades opened by a particular alpha model?
I've passed an identifying string with my insight but I can see that string is lost before it makes it into a PortfolioTarget, which is all I can access from a risk management module. At the risk management point, I can only see Symbol and Quantity, which is of no help to me.
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.
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.
Douglas Stridsberg
5.1k Pro
,
Clarification: it is lost when it's being made into a PortfolioTarget, as this does not accept any information about who generated the target. I can understand there are cases (probably most) where a Target is far removed from the Insight that generated it, but there are absolutely cases where the two are closely linked. IMO there should be a way to pass information along with the Target.
0
Jared Broad
Pro
,
Hey Douglas!
I definitely understand it would be helpful for your application to have data passed through the stack. Our vision for the framework is that the models will be interchangeable between algorithms, allowing you to pull in code from other people and use it in a "plug and play" manner. That forces us to use well-defined lines of communication between the modules.
https://imgur.com/a/M13MdeO
This does mean a little duplication between the modules but we think in the long run it'll be worthwhile. That said; if you really want to break the mold and adjust the targets based on the insights information you can do this with the event endpoint for the insights.
public class InsightTrackingRiskModel : RiskManagementModel
{
private List<Insight> _insights = new List<Insight>();
public InsightTrackingRiskModel(QCAlgorithmFramework algorithm)
{
algorithm.InsightsGenerated += OnInsightsGenerated;
}
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.
Douglas Stridsberg
5.1k Pro
,
Thank you for the insight into that event broadcast! Without having tried this in VS I am thinking there still is a missing link between the insight -> target -> position flow. I am not sure how to identify the position taken and what insight generated it, although I can also see cases where tying an insight to a positon is just not possible.
I'll think about this a bit more and see whether perhaps there's a very different way to achieve what I'm looking for.
0
Jared Broad
Pro
,
The Risk management generally should be considering the total portfolio created by the Portfolio Construction Model (PCM) and making sure it's within risk parameters. E.g. if the active or target positions are within drawdown limits. Generally, it shouldn't care about which insights generated those targets.
No one Insight necessarily translates directly to a portfolio target. This translation of Insights -> Targets is done by the PCM. For example, if multiple insights predict a drastic downturn in the market your PCM might act differently versus if there were just 1-2 negative signals.
============
I think your real question is: you have potential alpha in your exit signals. You should emit an InsightDirection.Flat when you think the Insight has terminated.
Or; if you want to make the exit signal a risk model; duplicate the alpha logic in the Risk model and adjust the relevant positions to flat when those symbols are looking risky.
0
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.
Douglas Stridsberg
5.1k Pro
,
Good shout about there being alpha in the exit signal and thus it belonging to the alpha model. I have used this approach before, but it required me to know (in the alpha model) whether there was a position on my symbol or not. And, in the example of a scalping system, it would require me to know when my position was opened and at what price (so that I could set a take-profit level). All of which should not be done in an alpha model.
In fact, let's say I wanted to exit a position some number of bars after it has been initiated: I see no way of finding the opening time of any of the algorithm.Portfolio.Holdings, and my algorithm.Transactions.TransactionRecord is empty even though I have a position open and algorithm.Transactions.OrdersCount == 1. Any ideas of how I would go about this, short of building and storing a separate record of trades inside the risk management model itself?
0
Jared Broad
Pro
,
Re: Take Profit: At every moment, whether your investment is above its starting position or not, a decline in the equity value is a loss and risk exposure. This might better define in a risk model - seeking to limit the risk. Here Take Profit => Limit Risk.
Re: Alpha Model: "know (in the alpha model) whether there was a position on my symbol or not". Consider the alpha model and insights are purely predicting the return of the asset. The moment the return of the asset turns negative it should emit a flat or negative signal regardless of the portfolio state. So here "Take Profit' => "End of Predicted Rise".
0
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.
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.
Loading...
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!