Back

Strategy Only Buys On First Year of Backtest

If have been trying my best to correct this error but I don't get where the problem is. Anyone has an idea why? I think the error might be on Coarse and Fine methods. 

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 Gonzalo,

The issue is with how you are setting self.month. if it is December, when you set self.month, you'll get a self.month value of 12 + 2 or 14. Which means self.Time.month < self.month will always be true and Universe.Unchanged will always be returned.We should account for this by taking the modulus of the self.Time.month + 2.

self.month = (self.Time.month + 2) % 12

It looks like you are attempting to rebalance every 2 months. You need other restrictions in place for this to work properly. For example, consider the case that self.month = 1; self.Time.month < self.month isn't a strong enough condition to prevent trading in November and December. We can supplement that if statement with

self.Time.month < self.month or (self.Time.month >= 11 and self.month <= 2)

This will make sure we aren't trading daily in Months 11 and 12.

Also note that once we return Universe.Unchanged in coarse selection, fine selection is not called. This means we only need to implement it once in coarse selection.

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.


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