/// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns>
        /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
        /// </returns>
        public bool MoveNext()
        {
            if (!_needNewCurrent)
            {
                // refresh on date change (in exchange time zone)
                _needNewCurrent = _timeProvider.GetUtcNow().ConvertFromUtc(_subscriptionRequest.Configuration.ExchangeTimeZone).Date != _lastEmitTime.Date;
            }

            if (_needNewCurrent)
            {
                if (!_universeProvider.CanPerformSelection())
                {
                    Current = null;
                    return(true);
                }

                var localTime = _timeProvider.GetUtcNow()
                                .RoundDown(_subscriptionRequest.Configuration.Increment)
                                .ConvertFromUtc(_subscriptionRequest.Configuration.ExchangeTimeZone);

                // loading the list of futures contracts and converting them into zip entries
                var symbols    = _universeProvider.LookupSymbols(_subscriptionRequest.Security.Symbol, false);
                var zipEntries = symbols.Select(x => new ZipEntryName {
                    Time = localTime, Symbol = x
                } as BaseData).ToList();
                var current = new BaseDataCollection
                {
                    Symbol  = _subscriptionRequest.Security.Symbol,
                    Data    = zipEntries,
                    Time    = localTime,
                    EndTime = localTime
                };

                _lastEmitTime = localTime;

                Log.Trace($"DataQueueFuturesChainUniverseDataCollectionEnumerator({current.Symbol}): Emitting data point: {current.EndTime}. Count: {current.Data.Count}");

                Current         = current;
                _needNewCurrent = false;
            }
            else
            {
                Current = null;
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Advances the enumerator to the next element of the collection.
        /// </summary>
        /// <returns>
        /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection.
        /// </returns>
        public bool MoveNext()
        {
            Underlying.MoveNext();

            if (Underlying.Current == null)
            {
                Current = null;
                return(true);
            }

            if (!_needNewCurrent)
            {
                // refresh on date change (in exchange time zone)
                _needNewCurrent = _timeProvider.GetUtcNow().ConvertFromUtc(_subscriptionRequest.Configuration.ExchangeTimeZone).Date != _lastEmitTime.Date;
            }

            if (_needNewCurrent)
            {
                if (!_universeProvider.CanPerformSelection())
                {
                    Current = null;
                    return(true);
                }

                var localTime = _timeProvider.GetUtcNow()
                                .RoundDown(_subscriptionRequest.Configuration.Increment)
                                .ConvertFromUtc(_subscriptionRequest.Configuration.ExchangeTimeZone);

                // loading the list of futures contracts and converting them into zip entries
                var symbols    = _universeProvider.LookupSymbols(_subscriptionRequest.Security.Symbol, false);
                var zipEntries = symbols.Select(x => new ZipEntryName {
                    Time = localTime, Symbol = x
                } as BaseData).ToList();
                _currentData = new OptionChainUniverseDataCollection
                {
                    Symbol     = _subscriptionRequest.Security.Symbol,
                    Underlying = Underlying.Current,
                    Data       = zipEntries,
                    Time       = localTime,
                    EndTime    = localTime
                };

                _lastEmitTime = localTime;

                Current         = _currentData;
                _needNewCurrent = false;
            }
            else
            {
                if (Current == null)
                {
                    Current = _currentData;
                }

                Current.Underlying = Underlying.Current;
                Current.Time       = Underlying.Current.EndTime;
                Current.EndTime    = Underlying.Current.EndTime;
            }

            return(true);
        }