public void DelistedSecuritiesInsightsTest(bool isDelisted, int expectedCount) { var algorithm = new QCAlgorithm(); algorithm.SubscriptionManager.SetDataManager(new DataManagerStub(algorithm)); algorithm.Transactions.SetOrderProcessor(new FakeOrderProcessor()); algorithm.SetStartDate(2007, 5, 16); algorithm.SetUniverseSelection(new ManualUniverseSelectionModel()); algorithm.SetFinishedWarmingUp(); var alpha = new FakeAlpha(); algorithm.SetAlpha(alpha); var construction = new FakePortfolioConstruction(); algorithm.SetPortfolioConstruction(construction); var actualInsights = new List <Insight>(); algorithm.InsightsGenerated += (s, e) => actualInsights.AddRange(e.Insights); var security = algorithm.AddEquity("SPY", Resolution.Daily); var tick = new Tick { Symbol = security.Symbol, Value = 1, Quantity = 2 }; security.SetMarketPrice(tick); security.IsDelisted = isDelisted; // Trigger Alpha to emit insight algorithm.OnFrameworkData(new Slice(new DateTime(2000, 01, 01), new List <BaseData>() { tick })); // Manually emit insight algorithm.EmitInsights(Insight.Price(Symbols.SPY, TimeSpan.FromDays(1), InsightDirection.Up, .5, .75)); // Should be zero because security is delisted Assert.AreEqual(expectedCount, actualInsights.Count); }