Пример #1
0
        public void ThrowsWhenEmptyReferencePrice()
        {
            var dividendProvider = new DividendEventProvider();
            var config           = new SubscriptionDataConfig(typeof(TradeBar), Symbols.AAPL, Resolution.Second, TimeZones.NewYork, TimeZones.NewYork,
                                                              false, false, false);
            var start = new DateTime(1998, 01, 02);
            var row1  = new DateTime(2000, 01, 02);
            var row2  = new DateTime(2001, 01, 02);
            var row3  = new DateTime(2002, 01, 02);

            var factorFile = new FactorFile("AAPL", new []
            {
                new FactorFileRow(row1, 0.693m, 1),
                new FactorFileRow(row2, 0.77m, 1),
                new FactorFileRow(row3, 0.85555m, 1)
            }, start);
            var mapFile = new LocalDiskMapFileProvider();

            dividendProvider.Initialize(config, factorFile, mapFile.Get(Market.USA).ResolveMapFile(Symbols.AAPL, start), start);

            foreach (var row in factorFile.Take(1))
            {
                var lastRawPrice = 100;
                var events       = dividendProvider
                                   .GetEvents(new NewTradableDateEventArgs(row.Date, null, Symbols.AAPL, lastRawPrice))
                                   .ToList();
                // ex dividend date does not emit anything
                Assert.AreEqual(0, events.Count);

                Assert.Throws <InvalidOperationException>(() =>
                {
                    dividendProvider
                    .GetEvents(new NewTradableDateEventArgs(row.Date.AddDays(1), null, Symbols.AAPL, lastRawPrice))
                    .ToList();
                });
            }
        }