public void UpdateClosingPricesUpdateExistingEntries() { 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); var prices = new StockPrice[] { new StockPrice(new Date(2000, 01, 03), 10.00m), new StockPrice(new Date(2000, 01, 05), 20.00m) }; priceHistory.UpdateClosingPrices(prices); var result = priceHistory.GetPrices(new DateRange(Date.MinValue, Date.MaxValue)).ToList(); result.Should().Equal(new[] { new StockPrice(new Date(2000, 01, 01), 1.00m), new StockPrice(new Date(2000, 01, 03), 10.00m), new StockPrice(new Date(2000, 01, 05), 20.00m) }); }
public void GetPriceExactMatch() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 08, 01), 4.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 10.00m); priceHistory.UpdateClosingPrice(new Date(2000, 05, 01), 6.00m); var result = priceHistory.GetPrice(new Date(2000, 01, 01)); result.Should().Be(10.00m); }
public void GetPriceCurrentDayWitoutCurrentPriceSet() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 08, 01), 4.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 10.00m); priceHistory.UpdateClosingPrice(new Date(2000, 05, 01), 6.00m); var result = priceHistory.GetPrice(Date.Today); result.Should().Be(4.00m); }
public void LatestDate() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 08, 01), 4.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 10.00m); priceHistory.UpdateClosingPrice(new Date(2000, 05, 01), 6.00m); var result = priceHistory.LatestDate; result.Should().Be(new Date(2000, 08, 01)); }
public void GetPriceBeforeFirstEntry() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 08, 01), 4.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 10.00m); priceHistory.UpdateClosingPrice(new Date(2000, 05, 01), 6.00m); priceHistory.UpdateCurrentPrice(15.00m); var result = priceHistory.GetPrice(new Date(1999, 02, 01)); result.Should().Be(0.00m); }
public void GetPriceInTheFuture() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 08, 01), 4.00m); priceHistory.UpdateClosingPrice(new Date(2000, 01, 01), 10.00m); priceHistory.UpdateClosingPrice(new Date(2000, 05, 01), 6.00m); priceHistory.UpdateCurrentPrice(15.00m); var result = priceHistory.GetPrice(Date.Today.AddDays(20)); result.Should().Be(15.00m); }
public void UpdateClosingPriceNoExistingEntryForDate() { 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, 04), 11.00m); var result = priceHistory.GetPrice(new Date(2000, 01, 04)); result.Should().Be(11.00m); }
public void UpdateClosingPriceCurrentPriceForDate() { 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.UpdateCurrentPrice(10.00m); priceHistory.UpdateClosingPrice(Date.Today, 11.00m); var result = priceHistory.GetPrice(Date.Today); result.Should().Be(11.00m); }
public void UpdateClosingPricesEmptyList() { var priceHistory = new StockPriceHistory(Guid.NewGuid()); priceHistory.UpdateClosingPrice(new Date(2000, 01, 04), 11.00m); var result = priceHistory.GetPrice(new Date(2000, 01, 04)); result.Should().Be(11.00m); }
public void GetPricesWhollyAfter() { 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(2001, 01, 01), new Date(2001, 01, 10))).ToList(); result.Should().BeEmpty(); }
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 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); }