18 using System.Collections.Generic;
33 private List<decimal> _uniqueStrikes;
34 private bool _refreshUniqueStrikes;
35 private DateTime _lastExchangeDate;
36 private readonly decimal _underlyingScaleFactor = 1;
60 _underlyingScaleFactor = option.SymbolProperties.StrikeMultiplier;
68 : base(allSymbols, underlying.EndTime)
71 _refreshUniqueStrikes =
true;
72 _underlyingScaleFactor = underlyingScaleFactor;
81 public void Refresh(IEnumerable<Symbol> allSymbols,
BaseData underlying, DateTime localTime)
83 base.Refresh(allSymbols, localTime);
86 _refreshUniqueStrikes = _lastExchangeDate != localTime.Date;
87 _lastExchangeDate = localTime.Date;
120 if (_refreshUniqueStrikes || _uniqueStrikes ==
null)
123 _uniqueStrikes = AllSymbols.Select(x => x.ID.StrikePrice)
125 .OrderBy(strikePrice => strikePrice)
127 _refreshUniqueStrikes =
false;
136 var exactPriceFound =
true;
146 exactPriceFound =
false;
148 if (index == ~_uniqueStrikes.Count)
151 AllSymbols = Enumerable.Empty<
Symbol>();
159 var indexMinPrice = index + minStrike;
160 var indexMaxPrice = index + maxStrike;
161 if (!exactPriceFound)
163 if (minStrike < 0 && maxStrike > 0)
167 else if (minStrike > 0)
174 if (indexMinPrice < 0)
178 else if (indexMinPrice >= _uniqueStrikes.Count)
181 AllSymbols = Enumerable.Empty<
Symbol>();
185 if (indexMaxPrice < 0)
188 AllSymbols = Enumerable.Empty<
Symbol>();
191 if (indexMaxPrice >= _uniqueStrikes.Count)
193 indexMaxPrice = _uniqueStrikes.Count - 1;
196 var minPrice = _uniqueStrikes[indexMinPrice];
197 var maxPrice = _uniqueStrikes[indexMaxPrice];
199 AllSymbols = AllSymbols
202 var price = symbol.ID.StrikePrice;
203 return price >= minPrice && price <= maxPrice;
242 universe.AllSymbols = universe.AllSymbols.Where(predicate).ToList();
254 universe.AllSymbols = universe.AllSymbols.Select(mapFunc).ToList();
266 universe.AllSymbols = universe.AllSymbols.SelectMany(mapFunc).ToList();
278 universe.AllSymbols = universe.AllSymbols.Where(filterList.Contains).ToList();