Modifying Insight Duration within Bootcamp: Algorithm Framework

Back

Hi There,

It is my understanding that when using the Algorithm Framework, Holdings will be implicitly Liquidated simply when an AlphaModel Insight signal duration has been met. 
I have been playing around with the code already provided in the Bootcamp: Algorithm Framework.
I tried modifying the Insight timedelta() argument (within the alpha model) and then, when that failed within the PortfolioConstructionModel as an argument passed to the EqualWeightingPortfolioConstructionModel.

This is how I modified the AlphaModel Insight timedelta() from 1 to 22:

return Insight.Group([Insight.Price(ordered[0]['symbol'], timedelta(22), InsightDirection.Up)

And this is how I modified the duration within the PortfolioConstruction model when the above failed to yield a result:

self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(rebalancingParam = timedelta(22)))

Both of these modifications resulted in the same number of trades as the original algorithm Insights, which were emitted daily.

Can you see what I am doing wrong? Is my understanding of Insight duration misguided? How should I stop the churn of daily trading?

Thanks in advance!

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.


Hi Mark,

The reason the algorithm generates insights every day is because Update is called daily and always returns 2 insights. We can adjust this to rebalance monthly by first utilizing the standard equal-weighting portfolio construction model.

self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())

Next, when we initialize our alpha model, it's month attribute is set to -1.

self.SetAlpha(MOMAlphaModel())

Then, in Update, we only return insights if a new month has started. We can achieve this by adding a guard to the top of the function definition.

if self.month == algorithm.Time.month:
return []
self.month = algorithm.Time.month

See the attached backtest code for a full working solution.

Best,
Derek

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