Back

How to get Security Insight Attributes?

Hi QC Community,

I am using QC Algorithm framework to develop my strategy. Currently, in the AlphaModel when I call the Update() function would like to know 2 things.

1. Current Security Insight direction? 

2. How long has the Insight been in that particular direction?

Are there any code snippets that someone can point me to for this?

Thanks!

 

 

Update Backtest







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.


Hey Joel,

I'm not sure if I understood the exact nature of your issue. Please feel free to clarify if I've missed the point. But if I've understood you correctly,

The Update method under the AlphaModel interface needs to return Insight objects.
An easy way to create an Insight is by using the Insight.Price method:

insight = Insight.Price("IBM", timedelta(minutes = 20), InsightDirection.Up)

Here InsightDirection.Up is the current security Insight direction,
and timedelta is how long that Insight has been in that direction.
In general, the Insights you create depend on the strategy you are implementing.

Please let me know whether I've addressed your questions. Otherwise, please clarify further. What are you trying to achieve?

Learn more about Insights and all of its attributes here:
https://www.quantconnect.com/docs/algorithm-framework/alpha-creation#Alpha-Creation-Creating-Insights

Best,
Rahul 

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.


Hi Rahul,

I am clear on how to create insights. 

What I am looking out for is if there is a way for me to check the current Security insight direction? e.g. yesterday the insight is down and today I want to check the previous day insight direction. Is there a way for me to do this without creating a rolling window to store the information? 

Another thing I am concern about is how long has the insight be in that particular direction?

 

0

Hi Joel Ong ,

QCAlgorithm doesn't have an "InsightManager" where all insights are stored.

If you just want to know the direction of the previous insight, you can assume that if the Security.Holdings.IsLong, the previous direction is InsightDirection.Up and InsightDirection.Down for Security.Holdings.IsShort.

However, since you also want to have information on the duration of the previous insights, you will have to store them. We have a helper class, InsightCollection, that can help:

class MyAlpha(AlphaModel):
def __init__(self):
self.insightCollection = InsightCollection()

def Update(self, algorithm, slice):
# Get insight that haven't expired of each symbol that is still in the universe
activeInsights = self.insightCollection.GetActiveInsights(algorithm.UtcTime)

insights = []
# LOGIC

# Save insights for the next iteration before return them
self.insightCollection.AddRange(insights)
return insights


 

1

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.


Update Backtest





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.


Loading...

This discussion is closed