Hi everyone,

I am using an equal-weighted algorithm framework to buy and hold 5 most liquid stocks 5 minutes before the market closes. Specifically, my algorithm is on minute resolution, and it will only emit a 5-day insights at 15:55pm everyday. I also used the provided EqualWeightingPortfolioConstructionModel with rebalance turned off. 

However, the order placement is not at all what I expected (see order below). MSFT was bought at 15:55pm and then immediately sold in the next morning. For other tickers, more shares were bought in the next morning for some unknown reason (I turned off rebalance).

Both a sample order history and full algorithm/backtest is attached. Can someone please help? Thank you!

2021-05-03 15:55:00	TSLA	Buy Market	
Fill: $684.28 USD
         29	Filled	
2021-05-03 15:55:00	AAPL	Buy Market	
Fill: $132.245370621 USD
  150	Filled
2021-05-03 15:55:00	MSFT	Buy Market	
Fill: $250.990433034 USD
  79	Filled	
2021-05-03 15:55:00	FB	    Buy Market	
Fill: $322.31 USD
         61	Filled	
2021-05-03 15:55:00	AMZN	Buy Market	
Fill: $3,382.03 USD 
       5	Filled	
2021-05-04 09:31:00	MSFT	Sell Market	
Fill: $250.182299112 USD
 -79    Filled	
2021-05-04 09:31:00	AMZN	Buy Market	
Fill: $3,356.20 USD
        2    Filled	
2021-05-04 09:31:00	FB	    Buy Market  Fill: $321.23 USD         16    Filled
... 

class buyBeforeMarketClose(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2021, 5, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.UniverseSettings.Resolution = Resolution.Minute
        self.AddUniverseSelection(
            FineFundamentalUniverseSelectionModel(self.SelectCoarse, self.SelectFine)
        )
        self.SetAlpha(buyBeforeMarketCloseAlphaModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel(rebalance = None))
        self.SetExecution(ImmediateExecutionModel())

    def SelectCoarse(self, coarse):
        # select top 3 most liquid
        mostliquid = sorted(coarse, key=lambda c: c.DollarVolume, reverse=True)[:5]

        return [c.Symbol for c in mostliquid]

    def SelectFine(self, fine):

        return [f.Symbol for f in fine]

class buyBeforeMarketCloseAlphaModel(AlphaModel):
    '''Buy 5 minutes before market close and hold for 5 days'''

    def __init__(self):
        self.securities = []
        self.insightPeriod = timedelta(days=5)
        self.direction = InsightDirection.Up

    def Update(self, algorithm, data):
        insights = []
        # buy 5 mins before market close
        if algorithm.Time.hour == 15 and algorithm.Time.minute == 55:
            for security in self.securities:
                insights.append(Insight.Price(security.Symbol, self.insightPeriod, self.direction))

        return insights

    def OnSecuritiesChanged(self, algorithm, changes):
        for added in changes.AddedSecurities:
            self.securities.append(added)