Hi everyone, so the basic premise of what this strategy is supposed to be doing is this:

On days SPY is down, buy stocks that are up at 9:45am, and sell everything at 3:45pm. But for some reason QuantConnect buys and sells stock at exact same price? The quote is the same. My code is attached below, I'm hoping someone can provide insight on what I'm doing wrong. Thank you.

"""
Buy 20 stocks showing strength vs SPY. Buy them. Liquidate at EOD

"""
class JumpingLightBrownScorpion(QCAlgorithm):

def Initialize(self):
self.SetStartDate(2018, 1, 1) # Set Start Date
self.SetCash(100000) # Set Cash

self.stocks = ["AAPL", "MSFT"] # stocks I'm interested in

# Dictionary to hold Symbol Data
self.symbolData = {}

for stock in self.stocks:
# Add equity data
symbol = self.AddEquity(stock, Resolution.Daily).Symbol
# Create symbol data for respective symbol
self.symbolData[symbol] = SymbolData(self, symbol)

self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol # intialize SPY
self.SetWarmUp(200, Resolution.Daily) # warm up indicators
self.yest_close = self.SMA(self.spy, 1, Resolution.Daily, Field.Close) # set SMA with close price as field



def OnData(self, data):
if self.IsWarmingUp or not self.yest_close.IsReady or not len(data.Bars) > 0: # if indicators warming up, not ready, or no data bars then stop
return

# Make sure indicators and rolling windows are ready
for symbol in self.symbolData.values():
if not symbol.IsReady:
return


if self.Time.hour == 9 and self.Time.minute == 45: # if it's 9:45am eastern
price = self.Securities[self.spy].Price # set price to SPYs price
yest_close = self.yest_close.Current.Value # set yesterday's closing price to variable

if price < yest_close:# If SPY fell from yesterday,
selected = []
for symbol, value in self.symbolData.items():
# If the SMA today is higher than SMA yesterday
sma_value = str(value.smaWindow[1])
sma_value = float((sma_value.split("-")[3]).strip())
if self.Securities[symbol].Price > sma_value:
selected.append(symbol)
for stock in selected:
self.SetHoldings(stock,1/len(selected))


if self.Time.hour == 15 and self.Time.minute == 45: # if it's 3:45pm eastern, liquidate portfolio
self.Liquidate()

class SymbolData:

def __init__(self, algorithm, symbol):
self.algorithm = algorithm
self.symbol = symbol
# Define our indicator
self.sma = algorithm.SMA(symbol, 1, Resolution.Daily, Field.Close)
# Define our rolling window to hold indicator points
self.smaWindow = RollingWindow[IndicatorDataPoint](2)
# Set our event handler
self.sma.Updated += self.OnSMAUpdated

def OnSMAUpdated(self, sender, updated):
# Add updated indicator data to rolling window
self.smaWindow.Add(updated)

@property
def IsReady(self):
return self.sma.IsReady and self.smaWindow.IsReady