/// <summary> /// Reads all ticks from the IBarsReader with TimeStamp property less than /// "until". /// </summary> public static IEnumerable <IBar> ReadUntilJustBefore(this IBarsReader reader, TimeStamp until) { while (reader.GetTimestampNextBarOrMaxValue() < until) { yield return(reader.ReadNext()); } }
/// <summary> /// Reads all available bars from the <paramref name="reader"/>. /// </summary> public static IEnumerable <IBar> ReadRemaining(this IBarsReader reader) { while (reader.ReadNext() is IBar bar) { yield return(bar); } }
/// <summary> /// Gets the TimeStamp property of the "PeekBar" in the <paramref /// name="reader"/>. Returns TimeStamp.MaxValue if no peek tick is /// available. /// </summary> public static TimeStamp GetTimestampNextBarOrMaxValue(this IBarsReader reader) { return(reader.PeekNext()?.TimeStamp ?? TimeStamp.MaxValue); }
/// <summary> /// Sets up the bar stream reader so that the next bar it returns via /// ReadNext() will have a timestampLocal property >= until. /// </summary> public static void MoveUntil(this IBarsReader reader, TimeStamp until) { // don't forget to call Count or something similar to actually run the enumerator reader.ReadUntilJustBefore(until).Count(); }