17 using System.Collections;
18 using System.Collections.Generic;
30 private readonly Dictionary<Type, Dictionary<Symbol, List<BaseData>>> _auxiliaryData =
new Dictionary<Type, Dictionary<Symbol, List<BaseData>>>();
97 Symbol = canonicalFutureSymbol;
115 public FuturesChain(
Symbol canonicalFutureSymbol, DateTime time, IEnumerable<BaseData> trades, IEnumerable<BaseData> quotes, IEnumerable<FuturesContract> contracts, IEnumerable<Symbol> filteredContracts)
118 Symbol = canonicalFutureSymbol;
127 foreach (var trade
in trades)
129 var tick = trade as
Tick;
133 if (!
Ticks.TryGetValue(tick.Symbol, out ticks))
135 ticks =
new List<Tick>();
136 Ticks[tick.Symbol] = ticks;
148 foreach (var quote
in quotes)
150 var tick = quote as
Tick;
154 if (!
Ticks.TryGetValue(tick.Symbol, out ticks))
156 ticks =
new List<Tick>();
157 Ticks[tick.Symbol] = ticks;
169 foreach (var contract
in contracts)
184 Dictionary<Symbol, List<BaseData>> dictionary;
185 if (!_auxiliaryData.TryGetValue(typeof(T), out dictionary) || !dictionary.TryGetValue(symbol, out list))
189 return list.OfType<T>().LastOrDefault();
199 Dictionary<Symbol, List<BaseData>> d;
200 if (!_auxiliaryData.TryGetValue(typeof(T), out d))
205 foreach (var kvp
in d)
207 var item = kvp.Value.OfType<T>().LastOrDefault();
210 dictionary.Add(kvp.Key, item);
223 Dictionary<Symbol, List<BaseData>> dictionary;
224 if (!_auxiliaryData.TryGetValue(typeof(T), out dictionary))
226 return new Dictionary<Symbol, List<BaseData>>();
240 Dictionary<Symbol, List<BaseData>> dictionary;
241 if (!_auxiliaryData.TryGetValue(typeof(T), out dictionary) || !dictionary.TryGetValue(symbol, out list))
243 return new List<T>();
245 return list.OfType<T>().ToList();
265 IEnumerator IEnumerable.GetEnumerator()
294 internal void AddAuxData(
BaseData baseData)
296 var type = baseData.GetType();
297 Dictionary<Symbol, List<BaseData>> dictionary;
298 if (!_auxiliaryData.TryGetValue(type, out dictionary))
300 dictionary =
new Dictionary<Symbol, List<BaseData>>();
301 _auxiliaryData[type] = dictionary;
305 if (!dictionary.TryGetValue(baseData.
Symbol, out list))
307 list =
new List<BaseData>();
308 dictionary[baseData.
Symbol] = list;