public void ReadsFactorFileWithExponentialNotation() { // Source NEWL factor file at 2019-12-09 var lines = new[] { "19980102,0.8116779,1e+07", "20051108,0.8116779,1e+07", "20060217,0.8416761,1e+07", "20060516,0.8644420,1e+07", "20060814,0.8747766,1e+07", "20061115,0.8901232,1e+07", "20070314,0.9082148,1e+07", "20070522,0.9166239,1e+07", "20070814,0.9306799,1e+07", "20071120,0.9534326,1e+07", "20080520,0.9830510,1e+07", "20100802,1.0000000,1e+07", "20131016,1.0000000,1.11111e+06", "20131205,1.0000000,75188", "20140305,1.0000000,25000", "20140514,1.0000000,2500", "20140714,1.0000000,50", "20501231,1.0000000,1" }; var factorFile = PriceScalingExtensions.SafeRead("PermTick", lines, SecurityType.Equity); Assert.AreEqual(5, factorFile.Count()); Assert.IsNotNull(factorFile.FactorFileMinimumDate); Assert.AreEqual(new DateTime(2013, 12, 04), factorFile.FactorFileMinimumDate.Value); }
public void ReadsOldFactorFileFormat() { var lines = new[] { "19980102,1.0000000,0.5", "20130828,1.0000000,0.5", "20501231,1.0000000,1" }; var factorFile = PriceScalingExtensions.SafeRead("bno", lines, SecurityType.Equity) as CorporateFactorProvider; var firstRow = factorFile.SortedFactorFileData[new DateTime(1998, 01, 02)].Single(); 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)].Single(); Assert.AreEqual(1m, secondRow.PriceFactor); Assert.AreEqual(0.5m, secondRow.SplitFactor); Assert.AreEqual(0m, firstRow.ReferencePrice); var thirdRow = factorFile.SortedFactorFileData[Time.EndOfTime].Single(); 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 = PriceScalingExtensions.SafeRead("bno", lines, SecurityType.Equity) as CorporateFactorProvider; 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 = PriceScalingExtensions.SafeRead("bno", lines, SecurityType.Equity) as CorporateFactorProvider; Assert.AreEqual(new DateTime(2013, 08, 28), factorFile.MostRecentFactorChange); }
public void HandlesUnknownDataMappingModes() { var lines = new[] { "{\"Date\":\"2010-01-28T00:00:00\",\"BackwardsRatioScale\":[1.1575],\"BackwardsPanamaCanalScale\":[7.06],\"ForwardPanamaCanalScale\":[0.0],\"DataMappingMode\":1}", "{\"Date\":\"2010-02-25T00:00:00\",\"BackwardsRatioScale\":[1.1575],\"BackwardsPanamaCanalScale\":[7.06],\"ForwardPanamaCanalScale\":[0.0],\"DataMappingMode\":788}" }; var factorFile = PriceScalingExtensions.SafeRead("cl", lines, SecurityType.Future) as MappingContractFactorProvider; Assert.AreEqual(1, factorFile.Count()); Assert.AreEqual(DataMappingMode.FirstDayMonth, (factorFile.First() as MappingContractFactorRow).DataMappingMode); }
public void ReadsFactorFileWithInfValues() { var lines = new[] { "19980102,1.0000000,inf", "20151211,1.0000000,inf", "20160330,1.0000000,2500", "20160915,1.0000000,80", "20501231,1.0000000,1" }; DateTime?factorFileMinimumDate; var factorFile = PriceScalingExtensions.SafeRead("PermTick", lines, SecurityType.Equity); Assert.AreEqual(3, factorFile.Count()); Assert.IsNotNull(factorFile.FactorFileMinimumDate); Assert.AreEqual(new DateTime(2016, 3, 29), factorFile.FactorFileMinimumDate.Value); }