Hi Community:
I'm backtesting a very basic mean-reversion stock strategy (see below), which generates insights on every Monday and lasts for 5 days. I expect the strategy to rebalance weekly. However, when I check the backtest results, I find that tradings happen throughout the week. How can this happen, given that new insights are only created on Mondays?
How should I revise the algorithm in order to achieve strict weekly rebalancing? Thanks.
Shile Wen
Hi Prometheus,
This is because the EqualWeightingPortfolioConstructionModel rebalances the portfolio throughout the week. To make it not rebalance, we can set it's rebalancing function to None. I've shown this in the attached backtest.
Best,
Shile Wen
Prometheus
Thanks a lot for your education, Shile. Setting the rebalancing function to None does work. Just for my learning of QuantConnect Algorithm Framework, I hope to understand that:
In my original code, EqualWeightingPortfolioConstruction is supposed to give equal target weight to all stocks with an active insight (with direction up or down). So within a week, given that the insights don't change, there should be no target weight change (and thus no trades), even if the rebalancing happens daily. So why do we see trades in the middle of the week?
Shile Wen
Hi Prometheus,
When the price of a stock increases, the portfolio value percentage of that stock will increase, thus, we will sell some off to rebalance the portfolio. The opposite happens when the price of a stock decreases.
Best,
Shile Wen
Prometheus
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!