Hi guys,
Here is what I'm hoping to do:
- If portfolio drawdown from start of day is below a threshold set all holdings to 0
- Also don't enter into any new transactions for the rest of the day
So I decided to do it in my alpha model and check for drawdown as a first step in the Update process. I set the Insights to flat and the Portfolio Target to 0 on the holding. This does not work though. Setting the portfolio target does nothing because it will be overwritten by the targets created from the Insights. However the targets created from the flat insights do not cause the sale of the holdings.
It seems at this point the only way to implement this will be with a custom PortfolioConstructionModel. Any recommendation or suggestions would be welcomed.
Cole S
The only way I have found to do this now is to call Liquidate from the Alpha model, but a more elegant solution would be preferred.
Rahul Chowdhury
Hey Kctrader,
The most elegant solution is to implement it in a RiskManagementModel. In general, it is good practice to keep the AlphaModel's calculations independent of the contents of the portfolio. It is also good practice to limit AlphaModel to emitting insights and not calling Liquidate within that class.
Cole S
Hi Rahul,
I tried my best to do that. The challenge is that the risk management model cannot expire the insights, so even if it sets the portfolio targets to 0 and exits the position, it will simply re-enter based on the unexpired insights. This is also a problem with the current RiskManagementModels, not just the one I want to implement.
We had a thread in Slack about it and there was some discussion about the best way to handle this going forward. Jared suggested adding the ability to expire insights.
Jared Broad
Thanks, KC we've added a Github issue for expiring insights and will get there ASAP.
If you can post a mock example of the risk model getting ignored it would help debug this. I think the model's outputs are meant to be "pulsing" not "steady-state", so if something is getting overridden/ignored we might need to really look into why.
Also really consider if you need the framework; if you need to control each trade you might not want to use the framework scaffolding.
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.
Cole S
Jared Broad Here is a backtest that shows the issue. A UGAZ insight is generated at 9:31 and the framework enters the position. The risk model exits the position shortly past 10am. At 12pm we generate an insight for DGAZ. At that point the framework enters an equal position on both DGAZ and UGAZ because the UGAZ insight has not expired.
I think the crux of the issue is that sending in additional insights for any security causes ProcessInsights to execute and it continues to use all unexpired insights, regardless of what the Risk Management Model has done.
I'll post this to Github as well.
Greg Kendall
Jared, is there any progress on this? I noticed that the issue is still open and not assigned on Github.
Is there a recommended workaround? -thanks.
Greg Kendall
Addition info FYI:
There is another forum post that goes into this further:
Cole S
Hey Greg,
What I came to realize is that I needed to implement my own PortfolioConstructionModel. This gives you much more control over how the insights are handled.
-Cole
Greg Kendall
If you didn't specify a time for an insight to last and instead, could you just re-issue the insights at whatever interval you are working with and if you need to liquidate then just issue "flat" insights for those stocks? The problem seems to be that the timeframe you add for insights to run causes them to constantly be re-issued even if you don't want them to be, because you want to liquidate then instead as in the case of a drawdown.
So if you don't put a time on the insights then they won't re-issue, right? Then if you make them "flat" they sell, right?
Another question: If you signal "up" over and over for the same stock will the equal weight portfolio manager just basically ignore the new ups since they are already in the portfolio? It really can't buy more if the stock is already bought, right? (Except for the minor weighting adjustments.)
(This insight alpha system appears to me to be very simplistic and underdeveloped. Maybe that is why the alpha market is being shutdown and revamped. It worked great when the fed was flooding the market with trillions and almost any hair-brained overfitted alpha would work. Now things are getting much more complicated and overfitting is going to kill you.)
Louis Szeto
Hi Greg
Yes, with a period that overlaps the previous insight, normally the same period.
This depends on the Portfolio Construction Model. The built-in PCM in LEAN follow that rule.
This depends on the Portfolio Construction Model. On built-in PCM in LEAN, if there are multiple insights of the same security, they consider the latest, so there is no cumulative effect.
Best
Louis
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.
Cole S
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!