19 using System.Collections;
20 using System.Collections.Generic;
33 private static readonly Dictionary<string, Symbol> _symbolsCache =
new();
35 private DateTime _endTime;
52 public List<BaseData>
Data {
get;
set; }
58 public override DateTime
EndTime
62 if (_endTime ==
default)
79 : this(DateTime.MinValue,
Symbol.Empty)
90 : this(time, time, symbol, data)
103 public BaseDataCollection(DateTime time, DateTime endTime,
Symbol symbol, IEnumerable<BaseData> data =
null,
BaseData underlying =
null, HashSet<Symbol> filteredContracts =
null)
104 : this(time, endTime, symbol, data != null ? data.ToList() : new List<
BaseData>(), underlying, filteredContracts)
118 : this(time, endTime, symbol, underlying, filteredContracts)
120 if (data !=
null && data.Count == 1 && data[0] is
BaseDataCollection collection && collection.
Data !=
null && collection.Data.Count > 0)
123 Data = collection.Data;
127 Data = data ??
new List<BaseData>();
160 var ticker = $
"{GetType().Name}-{market}-{Guid.NewGuid()}";
170 if (
Data ==
null ||
Data.Count == 0)
175 return Data[0].GetType() == GetType() ||
Data[0].ShouldCacheToSecurity();
184 Data.Add(newDataPoint);
191 public virtual void AddRange(IEnumerable<BaseData> newDataPoints)
193 Data.AddRange(newDataPoints);
214 return (
Data ?? Enumerable.Empty<
BaseData>()).GetEnumerator();
221 IEnumerator IEnumerable.GetEnumerator()
233 return _symbolsCache.TryGetValue(ticker, out symbol);
245 if (_symbolsCache.Count >= 600000)
247 _symbolsCache.Clear();
249 _symbolsCache.TryAdd(ticker, symbol);