I came across this while testing and end of month strategy. It seems, that QC is skipping some months entries, when using schedule.on():


from AlgorithmImports import *
from datetime import timedelta
from math import *

class GLDeom(QCAlgorithm) :
    def Initialize(self) :

        self.set_start_date(2009, 1, 1)
        self.set_end_date(2009, 12, 31)
        self.set_time_zone(TimeZones.NEW_YORK)
        self.set_cash(10000)
        self.set_brokerage_model(BrokerageName.ALPACA, AccountType.MARGIN)
        self.gld = self.add_equity("GLD", Resolution.MINUTE).symbol    

        # Schedule entry at end of month, 2 minutes before market close
        self.schedule.on(
            self.date_rules.month_end(),
            self.time_rules.before_market_close(self.gld, 2),
            self.enter_position
        )

    def enter_position(self) :
        self.debug(f"{self.time.date()}")

    def on_data(self, slice) :
        pass

Result:

5|3:34:46: 2009-03-31
6|3:34:46: 2009-04-30
7|3:34:46: 2009-06-30
8|3:34:46: 2009-07-31
9|3:34:46: 2009-08-31
10|3:34:46: 2009-09-30
11|3:34:46: 2009-11-30
12|3:34:46: Algorithm 'eae88f894063b8abd523cd01ca81e37e' completed
13|3:34:46: 2009-12-31

So monhts 1, 2, 5 and 10 are missing. What could be causing this?