/// <param name="approximateFirstMoveUntilDate"> /// Provide the approximate date of the first <see /// cref="MoveUntil(TimeStamp)"/> method call so that we can initialize the /// iterator so that the first <see cref="MoveUntil(TimeStamp)"/> call will /// result in the conditions specified in the commenting for <see /// cref="ISessionIterator"/>. /// </param> public TradingSessionIterator(TradingSessions tradingHours, DateStamp approximateFirstMoveUntilDate) { _tradingHours = tradingHours; var at = new TimeStamp(approximateFirstMoveUntilDate.AddDays(-12).DateTime.Ticks); Current = _tradingHours.GetActualSessionAt(at); Next = _tradingHours.GetActualSessionAt(Current.SessionEnd.AddTicks(1)); MoveNext(); MoveNext(); CurrentTime = Current.SessionStart.AddTicks(1); IsInSession = true; IsFirstTickOfSession = true; IsNewSession = true; }
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; }
private void MoveNext() { Previous = Current; Current = Next; Next = _tradingHours.GetActualSessionAt(Current.SessionEnd.AddTicks(1)); }