17 using System.Collections;
18 using System.Collections.Concurrent;
19 using System.Collections.Generic;
36 private TimeSpan? _minimumTimeInUniverseRoundingInterval;
43 private HashSet<Symbol> _previousSelections;
48 public virtual ConcurrentDictionary<Symbol, Member>
Securities
137 public Dictionary<Symbol, Security>
Members
139 get {
return Securities.Select(x => x.Value.Security).ToDictionary(x => x.Symbol); }
148 _previousSelections =
new HashSet<Symbol>();
149 Securities =
new ConcurrentDictionary<Symbol, Member>();
180 if (_minimumTimeInUniverseRoundingInterval ==
null)
184 AdjustMinimumTimeInUniverseRoundingInterval();
187 var timeInUniverse = utcTime - member.Added;
188 if (timeInUniverse.Round(_minimumTimeInUniverseRoundingInterval.Value)
209 return Enumerable.Empty<
Symbol>();
213 if (selections ==
null)
223 selections = result.ToHashSet();
227 var hasDiffs = _previousSelections.AreDifferent(selections);
228 _previousSelections = selections;
255 [Obsolete(
"CreateSecurity is obsolete and will not be called. The system will create the required Securities based on selected symbols")]
258 throw new InvalidOperationException(
"CreateSecurity is obsolete and should not be called." +
259 "The system will create the required Securities based on selected symbols");
269 [Obsolete(
"This overload is obsolete and will not be called. It was not capable of creating new SubscriptionDataConfig due to lack of information")]
272 throw new InvalidOperationException(
"This overload is obsolete and should not be called." +
273 "It was not capable of creating new SubscriptionDataConfig due to lack of information");
286 DateTime currentTimeUtc,
287 DateTime maximumEndTimeUtc,
290 var result = subscriptionService.
Add(security.
Symbol,
301 configuration: config,
302 startTimeUtc: currentTimeUtc,
303 endTimeUtc: maximumEndTimeUtc));
324 internal virtual bool AddMember(DateTime utcTime,
Security security,
bool isInternal)
337 return Securities.TryAdd(security.
Symbol,
new Member(utcTime, security, isInternal));
349 internal virtual bool RemoveMember(DateTime utcTime,
Security security)
387 IEnumerator<Symbol> IEnumerable<Symbol>.GetEnumerator() { yield
break; }
388 IEnumerator<string> IEnumerable<string>.GetEnumerator() { yield
break; }
389 IEnumerator IEnumerable.GetEnumerator() { yield
break; }
396 private void AdjustMinimumTimeInUniverseRoundingInterval()
398 if (_minimumTimeInUniverseRoundingInterval >= Time.OneDay)
400 _minimumTimeInUniverseRoundingInterval = Time.OneDay;
402 else if (_minimumTimeInUniverseRoundingInterval >= Time.OneHour)
404 _minimumTimeInUniverseRoundingInterval = Time.OneHour;
406 else if (_minimumTimeInUniverseRoundingInterval >= Time.OneMinute)
408 _minimumTimeInUniverseRoundingInterval = Time.OneMinute;
410 else if (_minimumTimeInUniverseRoundingInterval >= Time.OneSecond)
412 _minimumTimeInUniverseRoundingInterval = Time.OneSecond;
424 public DateTime
Added {
get; init; }