/// <summary>
        /// Creates an enumerator to read the specified request
        /// </summary>
        /// <param name="request">The subscription request to be read</param>
        /// <param name="dataProvider">Provider used to get data when it is not present on disk</param>
        /// <returns>An enumerator reading the subscription request</returns>
        public IEnumerator <BaseData> CreateEnumerator(SubscriptionRequest request, IDataProvider dataProvider)
        {
            var enumerator = (IEnumerator <BaseData>)_universe.GetTriggerTimes(request.StartTimeUtc, request.EndTimeUtc, _marketHoursDatabase)
                             .Select(x => new Tick {
                Time = x, Symbol = request.Configuration.Symbol
            })
                             .GetEnumerator();

            var universe = request.Universe as UserDefinedUniverse;

            if (universe != null)
            {
                enumerator = new InjectionEnumerator(enumerator);

                // Trigger universe selection when security added/removed after Initialize
                universe.CollectionChanged += (sender, args) =>
                {
                    // If it is an add we will set time 1 tick ahead to properly sync data
                    // with next timeslice, if it is a remove then we will set time to now
                    IList    items;
                    DateTime time;
                    if (args.Action == NotifyCollectionChangedAction.Add)
                    {
                        items = args.NewItems;
                        time  = _timeProvider.GetUtcNow().AddTicks(1);
                    }
                    else if (args.Action == NotifyCollectionChangedAction.Remove)
                    {
                        items = args.OldItems;
                        time  = _timeProvider.GetUtcNow();
                    }
                    else
                    {
                        items = null;
                        time  = DateTime.MinValue;
                    }

                    // Check that we have our items and time
                    if (items == null || time == DateTime.MinValue)
                    {
                        return;
                    }

                    var symbol = items.OfType <Symbol>().FirstOrDefault();

                    if (symbol == null)
                    {
                        return;
                    }

                    // the data point time should always be in exchange timezone
                    time = time.ConvertFromUtc(request.Configuration.ExchangeTimeZone);

                    var collection = new BaseDataCollection(time, symbol);
                    ((InjectionEnumerator)enumerator).InjectDataPoint(collection);
                };
            }

            return(enumerator);
        }
        /// <summary>
        /// Creates an enumerator to read the specified request
        /// </summary>
        /// <param name="request">The subscription request to be read</param>
        /// <param name="dataProvider">Provider used to get data when it is not present on disk</param>
        /// <returns>An enumerator reading the subscription request</returns>
        public IEnumerator <BaseData> CreateEnumerator(SubscriptionRequest request, IDataProvider dataProvider)
        {
            var enumerator = (IEnumerator <BaseData>)_universe.GetTriggerTimes(request.StartTimeUtc, request.EndTimeUtc, _marketHoursDatabase)
                             .Select(x => new Tick {
                Time = x, Symbol = request.Configuration.Symbol
            })
                             .GetEnumerator();

            var universe = request.Universe as UserDefinedUniverse;

            if (universe != null)
            {
                enumerator = new InjectionEnumerator(enumerator);

                // Trigger universe selection when security added/removed after Initialize
                universe.CollectionChanged += (sender, args) =>
                {
                    var items =
                        args.Action == NotifyCollectionChangedAction.Add ? args.NewItems :
                        args.Action == NotifyCollectionChangedAction.Remove ? args.OldItems : null;

                    var time = _timeProvider.GetUtcNow();
                    if (items == null || time == DateTime.MinValue)
                    {
                        return;
                    }

                    var symbol = items.OfType <Symbol>().FirstOrDefault();

                    if (symbol == null)
                    {
                        return;
                    }

                    // the data point time should always be in exchange timezone
                    time = time.ConvertFromUtc(request.Configuration.ExchangeTimeZone);

                    var collection = new BaseDataCollection(time, symbol);

                    ((InjectionEnumerator)enumerator).InjectDataPoint(collection);
                };
            }

            return(enumerator);
        }