public void ReadsOldFactorFileFormat() { var lines = new[] { "19980102,1.0000000,0.5", "20130828,1.0000000,0.5", "20501231,1.0000000,1" }; var factorFile = FactorFile.Parse("bno", lines); var firstRow = factorFile.SortedFactorFileData[new DateTime(1998, 01, 02)]; Assert.AreEqual(1m, firstRow.PriceFactor); Assert.AreEqual(0.5m, firstRow.SplitFactor); Assert.AreEqual(0m, firstRow.ReferencePrice); var secondRow = factorFile.SortedFactorFileData[new DateTime(2013, 08, 28)]; Assert.AreEqual(1m, secondRow.PriceFactor); Assert.AreEqual(0.5m, secondRow.SplitFactor); Assert.AreEqual(0m, firstRow.ReferencePrice); var thirdRow = factorFile.SortedFactorFileData[Time.EndOfTime]; Assert.AreEqual(1m, thirdRow.PriceFactor); Assert.AreEqual(1m, thirdRow.SplitFactor); Assert.AreEqual(0m, firstRow.ReferencePrice); }
public void EmptyFactorFileReturnsEmptyListForSplitsAndDividends(string contents) { var lines = contents.Split('\n').Where(l => !string.IsNullOrWhiteSpace(l)); var factorFile = FactorFile.Parse("bno", lines); Assert.IsEmpty(factorFile.GetSplitsAndDividends(Symbols.SPY, SecurityExchangeHours.AlwaysOpen(TimeZones.NewYork))); }
public void ResolvesCorrectMostRecentFactorChangeDate() { var lines = new[] { "19980102,1.0000000,0.5", "20130828,1.0000000,0.5", "20501231,1.0000000,1" }; var factorFile = FactorFile.Parse("bno", lines); Assert.AreEqual(new DateTime(2013, 08, 28), factorFile.MostRecentFactorChange); }