Assuming my algorithm forecasts that a security x will rise for y hours; is this the correct way to emit this insight?
self.EmitInsights((Insight(x.Symbol, timedelta(hours=y), InsightType.Price, InsightDirection.Up)))
If so, is it correct to emit this insight before my algorithm places the order to purchase x?
When I wish to liquidate this holding, does the algorithm need to emit a further insight which indicates that the position will be flattened? And if yes, how is this done correctly?
Rahul Chowdhury
Hey Kieran,
You are absolutely correct.
Insights need to be emitted before placing a trade. And a Flat Insight needs to be emitted with liquidate statements.
You can also specify other parameters like the magnitude of the insight, confidence, weight, etc when using the Insight() constructor.
For example,
Insight("IBM", timedelta(minutes=20), InsightType.Price, InsightDirection.Up, 0.0025, 1.00)
For price Insights, there is a helper method:
Insight.Price(ticker, timedelta, direction)
Learn more here about how EmitInsights work here:
https://www.quantconnect.com/docs/alpha-streams/upgrading-classic-algorithms#Upgrading-Classic-Algorithms-Converting-Classic-Algorithms
And learn more about creating insights here:
https://www.quantconnect.com/docs/alpha-streams/creating-an-alpha
Best,
Rahul
Kieran Flynn
Should InsightDirection.Flat be used to emit the flat insight?
Rahul Chowdhury
Hey Kieran,
Yes, InsightDirection.Flat should be used to emit flat insights.
Sergio Sierra
Hi,
Once the alpha model has sent an Insight, how should I use it in the main QCAlgorithm?
Varad Kabade
Hi Sergio David Sierra Marín,
The QCAlgorithm doesn't receive insights from the alpha model. The Portfolio Construction Model receives Insight objects from the Alpha Model and uses them to create PortfolioTarget objects for the execution model. Refer to this for further reference.
Best
Varad Kabade
Kieran Flynn
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!