My very first algo on QuantConnect. The error that I am getting is: "object has no attributable securities". Any help with debugging would be very much appreciated.

On a separate note, when making my very first step in Quantopian I liked priniting everything, so that I could see what is actually happening to the data. In this case, if I would like to print SPY daily Close prices and the moving average daily, how would I use the "debug" function?

Lastly, in the context below, if there any difference between self.securities["SPY"].Price and self.securities["SPY"].Close?

Many thanks in advance for all your help!

 

class EnergeticOrangeBuffalo(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2008, 1, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.spy = self.AddEquity("SPY", Resolution.Daily)
self.sma = self.SMA("SPY", 30, Resolution.Daily)



def OnData(self, data):
if not self.sma.IsReady:
return

if self.securities["SPY"].Price>self.sma.Current.Value:
self.SetHoldings("SPY", 1)
else:
self.SetHoldings("SPY", -1)