I am sure this is a very simple question for those with more experience with QC

 

I am trying to get the minute data from the past 3 minutes (current - 2 min, current - 1 min, current) to send to a function to determine what action to take.  This process should be repeated every minute from 10:02 AM until 3:59 PM at which point all assets would be liquidated.  What I have is partially as follows:

 

def Initialize(self):
        self.SetStartDate(2020, 1, 1)  # Set Start Date
        self.SetEndDate(2020, 1, 10)  # Set end Date
        self.SetCash(100000)  # Set Strategy Cash
        
        self.symbol = self.AddEquity("SPY", Resolution.Minute).Symbol
  

# get minute data              self.Schedule(self.DateRules.EveryDay(self.symbol),self.TimeRules.Every(TimeSpan.minutes(1)),Action(self.CheckDirection))
        
        # close all positions at the end of the day            
        self.Schedule(self.DateRules.EveryDay(self.symbol),self.TimeRules.At(15,59),self.ClosePositions)            

    def OnData(self, data):
        self.Plot("Data", self.symbol, self.Securities)
        
        # some action
        
    def CheckDirection(self):
        timeMinus = self.History(self.symbol, 2, Resolution.Minute)["timeMinus"]
        A = timeMinus(2)
        B = timeMinus(1)
        C = timeMinus(0)

... (the rest of this is just calculations, not relevant to getting the time-based data)

 

my intention is to get the 'timeMinus' matrix to update each minute with the last 3 minutes of data and then to assign current-2min to variable A, etc

 

I seem to be missing something syntactically, but am not sure what.  If you are able to help I would be most appreciative.

-J

Author