Hi! I tried to make a simple momentum strategy - buy best ETF if returns are positive for lookback period, rebalance monthly. I'm confused by the return function. Contrary to the size of the lookback period (63 days), I get a data interval (closing_bars) of 44, 43, 42 days. What am I doing wrong? Why are these numbers changing!?Where to read about how to warm up the algorithm correctly? I thought I did everything right, but I got an error
Thanks in advance for your help,
Ilya
Ilya mart
Understood with warming up, added
if self.IsWarmingUp:
return
in rebalance function
but the main issue with historical data has not gone away )
Ilya mart
I decided to add that the main idea was to test by months
Yuri Lopukhov
63 days would be 63 calendar days, but market days are 5 out of 7 (usually), that is why you get something close to 63/7*5=45 days. try using 90 days or more.
Ilya mart
Hi, Yuri! First of all thank you so much for your reply and time.
Just wanted to clarify one point, the documentation says that Quantconnect uses 1 day as 1 trading day in its calculations.
Do I understand correctly that we are now talking about calendar days? If yes, what then to do to get monthly data? 3, 6 months?
Yuri Lopukhov
Oh, I appologize, you are actually correct. I didn't know that SetWarmUp is intelligent enough for that.
Anyway, in your case the error is the same, but it is in the line
you should just use period here to use number of actual trading bars (trading days if Resolution.Daily is used), like this:
Using TimeSpan.FromDays or timedelta(days=period) here returns results based on calendar days instead.
Ilya mart
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!