Rebalancing skipped on non-trading days

Back

Hi all

I would like to rebalance my portfolio at every start of the month. However, I have noticed that if the start of the month happens to be on a weekend/public holidays, the rebalance will not occur. How can i code my algorithm in a way that if the start of the month happens on a non-trading day, the algorithm should not skip the rebalancing part for the month but rather rebalance on the next trading day?

Thank you! Appreciate all your help here.

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.


hello,
use a symbol
https://www.quantconnect.com/docs/algorithm-reference/scheduled-events#Scheduled-Events-Scheduled-Events
 # schedule an event to fire at the beginning of the month, the symbol is
# optional.
# if specified, it will fire the first trading day for that symbol of the month,
# if not specified it will fire on the first day of the month
self.Schedule.On(self.DateRules.MonthStart("SPY"), \
self.TimeRules.AfterMarketOpen("SPY"), \
self.RebalancingCode)

 
0

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