Exemple #1
0
        public SessionRespectingTickStreamReader(TradingSessions tradingSessions, ITickStreamReader tickStreamReader)
        {
            _tradingSessions  = tradingSessions;
            _tickStreamReader = tickStreamReader;
            var timeOfFirstTick        = tickStreamReader.PeekNext() !.TimeStamp;
            var sessionDateOfFirstTick = _tradingSessions.GetActualSessionAt(timeOfFirstTick).SessionDate;

            _iterator  = new TradingSessionIterator(_tradingSessions, sessionDateOfFirstTick);
            Instrument = tickStreamReader.Instrument;
        }
Exemple #2
0
        public Tick?PeekNext()
        {
            var tick = _tickStreamReader.PeekNext();

            if (tick is null)
            {
                return(null);
            }
            _iterator.MoveUntil(tick.TimeStamp);
            while (!_iterator.IsInSession)
            {
                _tickStreamReader.ReadNext();
                tick = _tickStreamReader.PeekNext();
                if (tick is null)
                {
                    return(null);
                }
                _iterator.MoveUntil(tick.TimeStamp);
            }

            return(tick);
        }
        /// <summary>
        /// Gets the TimeStamp property of the "PeekTick" in the ITickStreamReader.
        /// Returns TimeStamp.MaxValue if no peek tick is available.
        /// </summary>
        public static TimeStamp GetTimestampNextTickOrMaxValue(this ITickStreamReader reader)
        {
            var peekTick = reader.PeekNext();

            return(peekTick is null ? TimeStamp.MaxValue : peekTick.TimeStamp);
        }