public void GetInvestmentCandidates_NotEnoughtPeriods_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 = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Bid = 27.00m, Offer = 28.00m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Bid = 45.20m, Offer = 45.26m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Bid = 13.00m, Offer = 13.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()); }
public void GetPricesStartBeforeFirstEntryAndEndMatches() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 1.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 03), 3.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 05), 5.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 07), 7.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 09), 9.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 11), 11.00m); var result = priceHistory.GetPrices(new DateRange(new Date(1999, 01, 03), new Date(2000, 01, 05))).ToList(); result.Should().Equal(new[] { new StockPrice(new Date(2000, 01, 01), 1.00m), new StockPrice(new Date(2000, 01, 03), 3.00m), new StockPrice(new Date(2000, 01, 05), 5.00m) }); }
public void UpdateClosingPricesOnDelistingDate() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var stock = new Stock(id); stock.List("XYZ", "Existing Stock", new Date(1990, 01, 01), true, AssetCategory.AustralianFixedInterest); stock.DeList(new Date(1999, 01, 01)); var stockPriceHistory = new StockPriceHistory(id); stock.SetPriceHistory(stockPriceHistory); var stockCache = new EntityCache <Stock>(); stockCache.Add(stock); var stockQuery = new StockQuery(stockCache); var stockRepository = mockRepository.Create <IRepository <Stock> >(); var stockPriceHistoryCache = new EntityCache <StockPriceHistory>(); stockPriceHistoryCache.Add(stockPriceHistory); var stockPriceHistoryRepository = mockRepository.Create <IRepository <StockPriceHistory> >(); stockPriceHistoryRepository.Setup(x => x.Update(stockPriceHistory)).Verifiable(); var service = new StockService(stockQuery, stockCache, stockRepository.Object, stockPriceHistoryCache, stockPriceHistoryRepository.Object); var prices = new StockPrice[] { new StockPrice(new Date(1998, 01, 01), 0.10m), new StockPrice(new Date(1998, 12, 01), 0.20m), new StockPrice(new Date(1999, 01, 01), 0.30m) }; var result = service.UpdateClosingPrices(id, prices); result.Should().HaveOkStatus(); mockRepository.Verify(); }
public static async Task UpdateData(StockPriceHistory stockPriceHistory) { await stockPriceHistoryTable.UpdateAsync(stockPriceHistory); }
public static async Task InsertData(StockPriceHistory stockPriceHistory) { await stockPriceHistoryTable.InsertAsync(stockPriceHistory); }
public static async Task DeleteData(StockPriceHistory stockPriceHistory) { db.StockPriceHistories.Remove(stockPriceHistory); await db.SaveChangesAsync(); }
public static async Task InsertData(StockPriceHistory stockPriceHistory) { db.StockPriceHistories.Add(stockPriceHistory); await db.SaveChangesAsync(); }
public async static Task UpdateStockPriceHistory(StockPriceHistory stockPriceHistory) { await StockPriceHistoryDataAccess.UpdateData(stockPriceHistory); }
public async static Task InsertStockPriceHistory(StockPriceHistory stockPriceHistory) { await StockPriceHistoryDataAccess.InsertData(stockPriceHistory); }
public void GetInvestmentDecisions_BettingOnIncrease_ReturnsBet() { 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 = 27.23m, Offer = 23.23m }); history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-5) }, new Price { Bid = 28.23m, Offer = 24.23m }); history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-4) }, new Price { Bid = 30.23m, Offer = 26.23m }); history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-3) }, new Price { Bid = 32.23m, Offer = 28.23m }); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Bid = 32.23m, Offer = 28.23m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Bid = 33.23m, Offer = 29.23m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Bid = 37.23m, Offer = 33.23m }); var stockHistoryProvider = new Mock <IStockHistoryDataProvider>(); stockHistoryProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history); var accountDataProvider = new Mock <IAccountDataProvider>(); // We are willing to bet up to £100 per point, but only willing to loose £200, Also we accept that up to 75% of this loss can be because of the spread // GIVEN that our position is that the price will increase // AND that the BID price is 37.23 // AND the SPREAD is 4 points // WHEN we are willing to loose up to £150.00 on the spread // THEN the maximum bid we can afford to place is 150 / 4 = £37.23 (£37.00 giving an initial loss of £140.00) // GIVEN that our position is that the price will increase // AND that our bid amount is £37.00 per point // AND the maximum amount that we are willing to loose is £200.00 // WHEN the BID price is 37.23 // THEN the exit price will be 37.23 - (200 / 10) = 31.82 var decisionMaker = new DecisionByGrowthAndCurrentPosition(stockHistoryProvider.Object, accountDataProvider.Object, 5, 100m, 200m, .75m); var bets = decisionMaker.GetInvestmentDescisions(new Stock[] { stock }); var bet = bets.FirstOrDefault(); var stockPrice = history.Prices.Where(x => x.Key.Id == 7).Select(x => x.Value).Single(); Assert.IsNotNull(bet); Assert.AreEqual(37, bet.BidAmount); Assert.AreEqual(31.82m, bet.ExitPrice); Assert.AreEqual(37.23m, bet.OpeningPosition); Assert.AreEqual(stockPrice, bet.Price); Assert.AreEqual(Direction.Increase, bet.Direction); }
// GET: StockPriceHistory/Create public async Task <ActionResult> Create() { var stockPriceHistory = new StockPriceHistory(); return(View(stockPriceHistory)); }
public static Portfolio CreateEmptyPortfolio() { var arg = new Stock(Stock_ARG.Id); arg.List(Stock_ARG.AsxCode, Stock_ARG.Name, new Date(2000, 01, 01), false, AssetCategory.AustralianStocks); _StockCache.Add(arg); arg.CorporateActions.AddCapitalReturn(ARG_CapitalReturn, new Date(2001, 01, 01), "ARG Capital Return", new Date(2001, 01, 02), 10.00m); var argStockPrice = new StockPriceHistory(arg.Id); arg.SetPriceHistory(argStockPrice); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 01), 1.00m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 03), 1.01m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 04), 1.00m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 05), 1.03m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 06), 1.02m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 07), 1.01m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 10), 1.05m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 14), 1.07m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 17), 1.08m); argStockPrice.UpdateClosingPrice(new Date(2000, 01, 31), 1.09m); argStockPrice.UpdateClosingPrice(new Date(2000, 02, 29), 1.10m); argStockPrice.UpdateClosingPrice(new Date(2000, 03, 31), 1.07m); argStockPrice.UpdateClosingPrice(new Date(2000, 04, 28), 1.07m); argStockPrice.UpdateClosingPrice(new Date(2000, 05, 25), 1.03m); argStockPrice.UpdateClosingPrice(new Date(2000, 12, 29), 1.04m); argStockPrice.UpdateClosingPrice(new Date(2001, 01, 01), 1.05m); argStockPrice.UpdateClosingPrice(new Date(2001, 12, 31), 1.01m); argStockPrice.UpdateClosingPrice(new Date(2002, 12, 31), 0.99m); argStockPrice.UpdateClosingPrice(new Date(2003, 12, 31), 1.29m); argStockPrice.UpdateClosingPrice(new Date(2003, 05, 23), 1.40m); argStockPrice.UpdateClosingPrice(new Date(2007, 01, 02), 0.90m); argStockPrice.UpdateClosingPrice(new Date(2009, 01, 02), 1.70m); argStockPrice.UpdateClosingPrice(new Date(2010, 01, 01), 2.00m); var wam = new Stock(Stock_WAM.Id); wam.List(Stock_WAM.AsxCode, Stock_WAM.Name, new Date(2000, 01, 01), false, AssetCategory.AustralianStocks); _StockCache.Add(wam); wam.CorporateActions.AddSplitConsolidation(WAM_Split, new Date(2002, 01, 01), "WAM Split", 1, 2); var wamStockPrice = new StockPriceHistory(wam.Id); wam.SetPriceHistory(wamStockPrice); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 01), 1.20m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 03), 1.21m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 04), 1.20m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 05), 1.23m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 06), 1.22m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 07), 1.21m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 10), 1.25m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 14), 1.24m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 17), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2000, 01, 31), 1.28m); wamStockPrice.UpdateClosingPrice(new Date(2000, 02, 29), 1.29m); wamStockPrice.UpdateClosingPrice(new Date(2000, 03, 31), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2000, 04, 28), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2000, 05, 25), 1.23m); wamStockPrice.UpdateClosingPrice(new Date(2000, 12, 29), 1.14m); wamStockPrice.UpdateClosingPrice(new Date(2001, 01, 01), 1.15m); wamStockPrice.UpdateClosingPrice(new Date(2001, 12, 31), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2002, 12, 31), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2003, 12, 31), 1.27m); wamStockPrice.UpdateClosingPrice(new Date(2003, 05, 23), 1.40m); wamStockPrice.UpdateClosingPrice(new Date(2005, 01, 02), 1.10m); wamStockPrice.UpdateClosingPrice(new Date(2007, 01, 02), 0.90m); wamStockPrice.UpdateClosingPrice(new Date(2009, 01, 02), 1.30m); wamStockPrice.UpdateClosingPrice(new Date(2010, 01, 01), 1.50m); var portfolioFactory = new PortfolioFactory(StockResolver); var portfolio = portfolioFactory.CreatePortfolio(Guid.NewGuid()); portfolio.Create("Test", Guid.NewGuid()); // Remove Events portfolio.FetchEvents(); return(portfolio); }
public async Task InsertToDatabase(IStockQuoteFromDataSource stockData) { // get previous close price , if none, it's the first record and then insert to db IReadOnlyList <IStockPriceHistory> previousPrices = await _database.GetStockPriceHistoryAsync(stockData.Country.ConvertToTT2Country(), stockData.StockId, stockData.TradeDateTime, 1).ConfigureAwait(false); IStockPriceHistory previousStockPriceHistory = previousPrices?.FirstOrDefault(); if (previousStockPriceHistory == null) { //string msg = $"The stock data {GetStockFullID(todayPriceFromDataSource.StockId)} from data sourceKind doesn't have the previous closed price, so it will NOT be added to database"; //WriteToErrorLog(msg); IStockPriceHistory priceHist = new StockPriceHistory(stockData.Country.ConvertToTT2Country(), stockData.StockId, stockData.TradeDateTime) { OpenPrice = stockData.OpenPrice, ClosePrice = stockData.ClosePrice, HighPrice = stockData.HighPrice, LowPrice = stockData.LowPrice, Volume = stockData.Volume }; await _database.AddOrUpdateStockPriceHistoryAsync(priceHist).ConfigureAwait(false); return; } // get the max days of SystemN IReadOnlyList <IStockPriceHistory> recentStockPriceHistory = await _database.GetStockPriceHistoryAsync(stockData.Country.ConvertToTT2Country(), stockData.StockId, stockData.TradeDateTime, _maxCalculationDay - 1).ConfigureAwait(false); // if there exists previous closed price, then calculate today's ATR decimal todayATR = _baseData.CalculateTodayATR(stockData.HighPrice, stockData.LowPrice, previousStockPriceHistory.ClosePrice); (decimal? N20, decimal? HighIn20, decimal? LowIn10) = DailyPriceCalculationSystem(BuySellStrategyType.N20, recentStockPriceHistory, todayATR, stockData); (decimal? N40, decimal? HighIn40, decimal? LowIn15) = DailyPriceCalculationSystem(BuySellStrategyType.N40, recentStockPriceHistory, todayATR, stockData); (decimal? N60, decimal? HighIn60, decimal? LowIn20) = DailyPriceCalculationSystem(BuySellStrategyType.N60, recentStockPriceHistory, todayATR, stockData); decimal?MA20 = CalculateMovingAverage(20, recentStockPriceHistory, stockData); decimal?MA40 = CalculateMovingAverage(40, recentStockPriceHistory, stockData); decimal?MA60 = CalculateMovingAverage(60, recentStockPriceHistory, stockData); decimal?MA120 = CalculateMovingAverage(120, recentStockPriceHistory, stockData); decimal?MA240 = CalculateMovingAverage(240, recentStockPriceHistory, stockData); IStockPriceHistory priceHistory = new StockPriceHistory(stockData.Country.ConvertToTT2Country(), stockData.StockId, stockData.TradeDateTime) { OpenPrice = stockData.OpenPrice, ClosePrice = stockData.ClosePrice, HighPrice = stockData.HighPrice, LowPrice = stockData.LowPrice, Volume = stockData.Volume, ATR = todayATR, N20 = N20, N40 = N40, N60 = N60, HighIn20 = HighIn20, LowIn10 = LowIn10, HighIn40 = HighIn40, LowIn15 = LowIn15, HighIn60 = HighIn60, LowIn20 = LowIn20, MA20 = MA20, MA40 = MA40, MA60 = MA60, MA120 = MA120, MA240 = MA240 }; await _database.AddOrUpdateStockPriceHistoryAsync(priceHistory).ConfigureAwait(false); }
public static void Initialize(VestHQDbContext context) { context.Database.EnsureCreated(); if (context.Customers.Any()) { return; // DB has been seeded } var stocks = new Stock[] { new Stock { Name = "Microsoft", Symbol = "MSFT" }, new Stock { Name = "Apple", Symbol = "AAPL" }, new Stock { Name = "General Motors", Symbol = "GM" }, }; foreach (Stock s in stocks) { context.Stocks.Add(s); } context.SaveChanges(); var stockpricehistory = new StockPriceHistory[] { new StockPriceHistory { StockId = 1, Date = DateTime.Parse("2017-04-07 T17:30:00"), Price = 65.73 }, new StockPriceHistory { StockId = 2, Date = DateTime.Parse("2017-04-07 T17:30:00"), Price = 143.66 }, new StockPriceHistory { StockId = 3, Date = DateTime.Parse("2017-04-07 T17:30:00"), Price = 40.60 }, new StockPriceHistory { StockId = 1, Date = DateTime.Parse("2017-04-08 T17:30:00"), Price = 66 }, new StockPriceHistory { StockId = 2, Date = DateTime.Parse("2017-04-08 T17:30:00"), Price = 140 }, new StockPriceHistory { StockId = 3, Date = DateTime.Parse("2017-04-08 T17:30:00"), Price = 41 }, }; foreach (StockPriceHistory sph in stockpricehistory) { context.StockPriceHistories.Add(sph); } context.SaveChanges(); var Employer = new Employer[] { new Employer { EmployerName = "VestHQ No1" }, new Employer { EmployerName = "VestHQ No2" }, }; foreach (Employer e in Employer) { context.Employers.Add(e); } context.SaveChanges(); var Customer = new Customer[] { new Customer { FirstName = "Doris", LastName = "Chen", TwitterAccount = "dchen", EmployerId = 1 }, new Customer { FirstName = "David", LastName = "Giard", TwitterAccount = "dgiard", EmployerId = 2 }, }; foreach (Customer c in Customer) { context.Customers.Add(c); } context.SaveChanges(); var Holding = new Holding[] { new Holding { StockId = 1, CustomerId = 1, Share = 2000 }, new Holding { StockId = 1, CustomerId = 2, Share = 2500 }, new Holding { StockId = 2, CustomerId = 1, Share = 1000 }, new Holding { StockId = 3, CustomerId = 2, Share = 500 } }; foreach (Holding h in Holding) { context.Holdings.Add(h); } context.SaveChanges(); }
public void GetInvestmentCandidates_RateOfReductionSufficient_ReturnsStock() { 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 = 1, To = lastPeriodEnd.AddHours(-6) }, new Price { Mid = 25.23m }); history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-5) }, new Price { Mid = 24.23m }); history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-4) }, new Price { Mid = 23.23m }); history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-3) }, new Price { Mid = 22.23m }); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Mid = 21.25m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-1) }, new Price { Mid = 20.50m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(0) }, new Price { Mid = 20.40m }); var stockPriceProvider = new Mock <IStockHistoryDataProvider>(); stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history); var filter = new MinimumRateOfChangeStockFilter(stockPriceProvider.Object, 5, 10m, 10m); var results = filter.GetInvestmentCandidates(new Stock[] { stock }); Assert.AreEqual(1, results.Count()); }
public void GetInvestmentCandidates_LatestPeriodMissing_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 = 1, To = lastPeriodEnd.AddHours(-8) }, new Price { Mid = 45.23m }); history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-7) }, new Price { Mid = 43.23m }); history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-6) }, new Price { Mid = 30.23m }); history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-5) }, new Price { Mid = 29.23m }); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-4) }, new Price { Mid = 27.25m }); history.Prices.Add(new Period { Id = 6, To = lastPeriodEnd.AddHours(-3) }, new Price { Mid = 18.50m }); history.Prices.Add(new Period { Id = 7, To = lastPeriodEnd.AddHours(-2) }, 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_RateOfGrowthInsufficient_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 = 25.20m, Offer = 25.26m }); history.Prices.Add(new Period { Id = 2, To = lastPeriodEnd.AddHours(-5) }, new Price { Bid = 26.20m, Offer = 26.26m }); history.Prices.Add(new Period { Id = 3, To = lastPeriodEnd.AddHours(-4) }, new Price { Bid = 28.20m, Offer = 28.26m }); history.Prices.Add(new Period { Id = 4, To = lastPeriodEnd.AddHours(-3) }, new Price { Bid = 30.20m, Offer = 30.26m }); history.Prices.Add(new Period { Id = 5, To = lastPeriodEnd.AddHours(-2) }, new Price { Bid = 30.00m, Offer = 30.50m }); 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 = 35.00m, Offer = 35.80m }); var stockPriceProvider = new Mock <IStockHistoryDataProvider>(); stockPriceProvider.Setup(x => x.GetStockHistory(stock, 5)).Returns(history); var filter = new MinimumRateOfChangeStockFilter(stockPriceProvider.Object, 5, 35m, 35m); var results = filter.GetInvestmentCandidates(new Stock[] { stock }); Assert.AreEqual(0, results.Count()); }