public void TestVWSPNoTradesInLastFiveMinutes() { CommonStock commonStock = new CommonStock("Test", 8, 100); var now = DateTime.Now; var sixMinsFromNow = now.AddMinutes(6); var sevenMinsFromNow = now.AddMinutes(7); var sixMinsBeforeNow = now.AddMinutes(-6); var firstTrade = new Trade(1, TradeIndicator.Buy, 10, sixMinsFromNow); var secondTrade = new Trade(1, TradeIndicator.Buy, 10, sevenMinsFromNow); var thirdTrade = new Trade(1, TradeIndicator.Buy, 10, sixMinsBeforeNow); commonStock.AddNewTrade(firstTrade); commonStock.AddNewTrade(secondTrade); commonStock.AddNewTrade(thirdTrade); Assert.AreEqual(commonStock.CalculateVolumeWeightedStockPrice(), 0); }
public void TestVolumeWeightedStockPrice() { CommonStock commonStock = new CommonStock("Test", 8, 100); var now = DateTime.Now; var oneMinsBeforeNow = now.AddMinutes(-1); var twoMinsBeforeNow = now.AddMinutes(-2); var threeMinsBeforeNow = now.AddMinutes(-3); var firstTrade = new Trade(1, TradeIndicator.Buy, 10, oneMinsBeforeNow); var secondTrade = new Trade(2, TradeIndicator.Buy, 10, twoMinsBeforeNow); var thirdTrade = new Trade(3, TradeIndicator.Buy, 10, threeMinsBeforeNow); commonStock.AddNewTrade(firstTrade); commonStock.AddNewTrade(secondTrade); commonStock.AddNewTrade(thirdTrade); Assert.AreEqual(commonStock.CalculateVolumeWeightedStockPrice(), 10); }