18 using System.Collections;
19 using System.Collections.Generic;
38 private readonly
bool _liveMode;
40 private readonly DateTime _endTime;
41 private readonly
bool _extendedMarketHours;
44 private readonly IEnumerator<BaseData> _enumerator;
62 filter.DataFilterError += (sender, exception) =>
64 Log.
Error(exception,
"WrapForDataFeed");
65 resultHandler.
RuntimeError(
"Runtime error applying data filter. Assuming filter pass: " + exception.Message, exception.StackTrace);
82 _enumerator = enumerator;
85 _exchangeHours = securityExchangeHours;
86 _dataFilter = _security.DataFilter;
87 _extendedMarketHours = extendedMarketHours;
109 object IEnumerator.Current
123 while (_enumerator.MoveNext())
125 var current = _enumerator.Current;
131 if (current.DataType !=
MarketDataType.Auxiliary && !_dataFilter.Filter(_security, current))
136 catch (Exception err)
138 OnDataFilterError(err);
143 if (current.DataType !=
MarketDataType.Auxiliary && !_exchangeHours.IsOpen(current.Time, current.EndTime, _extendedMarketHours))
145 if (_liveMode && !current.IsFillForward)
148 _security.SetMarketPrice(current);
154 if (current.Time > _endTime)
173 _enumerator.Dispose();
189 private void OnDataFilterError(Exception exception)
192 if (handler !=
null) handler(
this, exception);