17 using System.Collections.Generic;
30 private readonly Dictionary<Symbol, List<SubscriptionRequest>> _subscriptionRequests;
37 public EventHandler<SubscriptionRequest>
Added {
get;
set; }
42 public EventHandler<SubscriptionRequest>
Removed {
get;
set; }
51 _algorithm = algorithm;
52 _resolution = resolution;
53 _subscriptionRequests =
new Dictionary<Symbol, List<SubscriptionRequest>>();
62 if (PreFilter(request))
65 List<SubscriptionRequest> internalRequests;
66 var existing = _subscriptionRequests.TryGetValue(request.
Configuration.
Symbol, out internalRequests);
67 var alreadyInternal = existing && internalRequests.Any(internalRequest => internalRequest.Configuration.Type == request.
Configuration.
Type
70 if (lowResolution && !alreadyInternal)
76 if (_algorithm.IsWarmingUp)
80 startTimeUtc = DateTime.UtcNow;
89 _subscriptionRequests[request.
Configuration.
Symbol] =
new List<SubscriptionRequest>{ internalRequest };
91 Added?.Invoke(
this, internalRequest);
93 else if (!lowResolution && alreadyInternal)
97 foreach (var subscriptionRequest
in internalRequests)
99 Removed?.Invoke(
this, subscriptionRequest);
113 var userConfigs = _algorithm.SubscriptionManager.SubscriptionDataConfigService
116 if (userConfigs.Count == 0 || userConfigs.Any(config => config.Resolution <=
Resolution.Minute))
121 foreach (var subscriptionRequest
in requests)
123 Removed?.Invoke(
this, subscriptionRequest);