I can't use the AfterMarketOpen function. In my initialize function, I'm calling

self.Schedule.On(self.DateRules.EveryDay(), self.TimeRules.AfterMarketOpen( "SPY", -1 ), my_function)

in order to execute my_function just before market open. However, I get the following error:

TypeError : unindexable object     (Open Stacktrace)

In the QC documentation it says the AfterMarketOpen function can be called as such:

TimeRules.AfterMarketOpen("SPY", 10)

On the other hand, the API says the first parameter should be of type QuantConnect.Symbol. I tried that, but it still won't work. What should I do?