public void AggregatesUntilTimeChange()
        {
            var time = new DateTime(2015, 10, 20);
            var underlying = Enumerable.Range(0, 5).Select(x => new Tick { Time = time }).ToList();
            underlying.AddRange(Enumerable.Range(0, 5).Select(x => new Tick {Time = time.AddSeconds(1)}));

            var aggregator = new BaseDataCollectionAggregatorEnumerator(underlying.GetEnumerator(), "underlying");

            Assert.IsTrue(aggregator.MoveNext());
            Assert.IsNotNull(aggregator.Current);
            Assert.AreEqual(5, aggregator.Current.Data.Count);
        }
        public void AggregatesUntilNull()
        {
            var time = new DateTime(2015, 10, 20);
            var underlying = Enumerable.Range(0, 5).Select(x => new Tick { Time = time }).ToList();
            underlying.AddRange(new Tick[] { null, null, null });

            var aggregator = new BaseDataCollectionAggregatorEnumerator(underlying.GetEnumerator(), Symbols.SPY);

            Assert.IsTrue(aggregator.MoveNext());
            Assert.IsNotNull(aggregator.Current);
            Assert.AreEqual(5, aggregator.Current.Data.Count);
        }
Beispiel #3
0
        /// <summary>
        /// Configure the enumerator with aggregation/fill-forward/filter behaviors. Returns new instance if re-configured
        /// </summary>
        private IEnumerator<BaseData> ConfigureEnumerator(SubscriptionRequest request, bool aggregate, IEnumerator<BaseData> enumerator)
        {
            if (aggregate)
            {
                enumerator = new BaseDataCollectionAggregatorEnumerator(enumerator, request.Configuration.Symbol);
            }

            // optionally apply fill forward logic, but never for tick data
            if (request.Configuration.FillDataForward && request.Configuration.Resolution != Resolution.Tick)
            {
                enumerator = new FillForwardEnumerator(enumerator, request.Security.Exchange, _fillForwardResolution,
                    request.Security.IsExtendedMarketHours, request.EndTimeLocal, request.Configuration.Resolution.ToTimeSpan());
            }

            // optionally apply exchange/user filters
            if (request.Configuration.IsFilteredSubscription)
            {
                enumerator = SubscriptionFilterEnumerator.WrapForDataFeed(_resultHandler, enumerator, request.Security, request.EndTimeLocal);
            }

            return enumerator;
        }