I'm trying to write an algorithm that will do Universe Selection and Alpha Insights emission once a year on 15 Jan. However, in the code below, no trades get executed in the entire month of Jan. Why is that? How can I fix this?
QUANTCONNECT COMMUNITY
I'm trying to write an algorithm that will do Universe Selection and Alpha Insights emission once a year on 15 Jan. However, in the code below, no trades get executed in the entire month of Jan. Why is that? How can I fix this?
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.
Arthur Asenheimer
Hi Victor,Â
by default the EqualWeightingPortfolioConstructionModel rebalances with the specified resolution (which is Resolution.Daily here). To avoid this, just pass "lambda time: None" to your PortfolioConstructionModel and useÂ
self.Settings.RebalancePortfolioOnSecurityChanges = True
self.Settings.RebalancePortfolioOnInsightChanges = False
 to make sure the algorithm will rebalance only when there were changes in your universe (which is 15th january).Â
I've attached a backtest which should meet your criteria.
Let me know if you have further questions.
Â
some additional notes:Â
- self.Time.date is a method, if you want to call this function you need self.Time.date(). But keep in mind this would return a tuple (year, month, day). I've replaced it with self.Time.day for your purpose.Â
- if CoarseSelectionFunction returns UniverseUnchanged it will skip FineSelectionFunction, so you don't need to return UniverseUnchanged there.Â
- keep in mind that trading only at 15th jan is not a stable solution since this could falls on a weekend. however, i guess you just mentioned it for demo/testing purposes.Â
Victor Lin
Thank you so much, Arthur! You have greatly furthered my understanding of QC.
Victor Lin
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!