I am trying to initialize a list that contains the low price for SPY for the past 4 days at the initialization stage. However, it is giving me an error saying that the history object has no attribute ‘itertuples’ when I try to append to my list. And it seems like self.History is not return a dataframe object. Did I miss a step somewhere?

Code:

class CryingAsparagusKoala(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 2, 16)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.AddEquity("SPY", Resolution.Daily)
        
        self.low = []
        history = self.History("SPY", 4, Resolution.Daily)
        self.Log("history is type:".format(type(history)))
        for bar in history.itertuples():
            self.low.append(bar.close)
        

    def OnData(self, data):

        if not self.Portfolio.Invested:
            self.SetHoldings("SPY", 1)

 

Error:


During the algorithm initialization, the following exception has occurred: AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'itertuples'
  at Initialize
    for bar at history.itertuples():
===
   at Python.Runtime.PyObject.Invoke(PyTuple args in main.py: line 11

 AttributeError : '0, Culture=neutral, PublicKeyToken=null]]' object has no attribute 'itertuples'