There is a bug when using consolidators with Calendar.Monthly and Calendar.Yearly with daily resolution data.

Specifically, a 1-day consolidated bar will be thrown out of the consolidated handler on the start date of the backtest:

127853_1650438273.jpg

This is the code:

class PensiveFluorescentPinkBeaver(QCAlgorithm):

    def Initialize(self):
        
        # Set Start Date
        self.SetStartDate(2019, 1, 1)
        self.SetEndDate(2019, 5, 1)
        
        # Set Strategy Cash
        self.SetCash(100000) 
        
        # AAPL
        symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol

        # Consolidate daily bars to monthly Bars
        self.Consolidate(symbol, Calendar.Monthly, self.MonthlyHandler)

    def OnData(self, data: Slice):
        pass
    
    def MonthlyHandler(self, bar):

        self.Debug(bar.Close)

Author