public void GetInvestmentCandidates_NotEnoughtPeriods_ReturnsNothing() { var stock = new Stock { Id = "STK.PLC", Name = "STOCK PLC", Description = "The Test Stock Price" }; var history = new StockPriceHistory { Stock = stock, Prices = new Dictionary <Period, Price>() }; var currentDate = DateTime.UtcNow.AddMinutes(10); var lastPeriodEnd = DateTime.Parse(currentDate.ToString("dd MMMM yyyy HH:00:00")); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Mid = 27.25m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Mid = 18.50m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Mid = 13.40m }); var stockPriceProvider = new Mock <IStockHistoryDataProvider>(); stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history); var filter = new ConsistentChangeStockFilter(stockPriceProvider.Object, 5); var results = filter.GetInvestmentCandidates(new Stock[] { stock }); Assert.AreEqual(0, results.Count()); }
public void GetInvestmentCandidates_PriceDecreasesAndIncreases_ReturnsNothing() { var stock = new Stock { Identifier = "STK.PLC", Name = "STOCK PLC", Description = "The Test Stock Price" }; var history = new StockPriceHistory { Stock = stock, Prices = new Dictionary <Period, Price>() }; var currentDate = DateTime.UtcNow.AddMinutes(10); var lastPeriodEnd = DateTime.Parse(currentDate.ToString("dd MMMM yyyy HH:00:00")); history.Prices.Add(new Period { Id = 1, To = lastPeriodEnd.AddHours(-6) }, new Price { Bid = 45.20m, Offer = 45.26m }); history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-5) }, new Price { Bid = 45.20m, Offer = 45.26m }); history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-4) }, new Price { Bid = 30.20m, Offer = 30.26m }); history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-3) }, new Price { Bid = 29.20m, Offer = 29.26m }); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Bid = 30.00m, Offer = 31.00m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Bid = 31.00m, Offer = 32.00m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Bid = 32.00m, Offer = 32.80m }); var stockPriceProvider = new Mock <IStockHistoryDataProvider>(); stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history); var filter = new ConsistentChangeStockFilter(stockPriceProvider.Object, 5); var results = filter.GetInvestmentCandidates(new Stock[] { stock }); Assert.AreEqual(0, results.Count()); }