19 using System.Collections;
20 using System.Collections.Generic;
32 private static readonly Dictionary<string, Symbol> _symbolsCache =
new();
34 private DateTime _endTime;
49 public List<BaseData>
Data {
get;
set; }
54 public override DateTime
EndTime
58 if (_endTime ==
default)
75 : this(DateTime.MinValue,
Symbol.Empty)
86 : this(time, time, symbol, data)
99 public BaseDataCollection(DateTime time, DateTime endTime,
Symbol symbol, IEnumerable<BaseData> data =
null,
BaseData underlying =
null, HashSet<Symbol> filteredContracts =
null)
100 : this(time, endTime, symbol, data != null ? data.ToList() : new List<
BaseData>(), underlying, filteredContracts)
114 : this(time, endTime, symbol, underlying, filteredContracts)
116 if (data !=
null && data.Count == 1 && data[0] is
BaseDataCollection collection && collection.
Data !=
null && collection.Data.Count > 0)
119 Data = collection.Data;
123 Data = data ??
new List<BaseData>();
156 var ticker = $
"{GetType().Name}-{market}-{Guid.NewGuid()}";
166 if (
Data ==
null ||
Data.Count == 0)
171 return Data[0].GetType() == GetType() ||
Data[0].ShouldCacheToSecurity();
180 Data.Add(newDataPoint);
187 public virtual void AddRange(IEnumerable<BaseData> newDataPoints)
189 Data.AddRange(newDataPoints);
210 return (
Data ?? Enumerable.Empty<
BaseData>()).GetEnumerator();
217 IEnumerator IEnumerable.GetEnumerator()
229 return _symbolsCache.TryGetValue(ticker, out symbol);
241 if (_symbolsCache.Count >= 600000)
243 _symbolsCache.Clear();
245 _symbolsCache.TryAdd(ticker, symbol);