Esempio n. 1
0
        public Dictionary <string, List <BarScaleInterval> > SymbolsScaleIntervalsQuoteConsumerRegistered(IStreamingConsumer consumer)
        {
            Dictionary <string, List <BarScaleInterval> > ret = null;

            foreach (string symbol in this.DistributionChannels.Keys)
            {
                Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> consumersByScaleInterval = DistributionChannels[symbol];
                foreach (BarScaleInterval scaleInterval in consumersByScaleInterval.Keys)
                {
                    SymbolScaleDistributionChannel consumers = consumersByScaleInterval[scaleInterval];
                    if (consumers.ConsumersQuoteContains(consumer))
                    {
                        if (ret == null)
                        {
                            ret = new Dictionary <string, List <BarScaleInterval> >();
                        }
                        if (ret.ContainsKey(symbol) == false)
                        {
                            ret.Add(symbol, new List <BarScaleInterval>());
                        }
                        ret[symbol].Add(scaleInterval);
                    }
                }
            }
            return(ret);
        }
Esempio n. 2
0
 public void ConsumerQuoteRegister(string symbol, BarScaleInterval scaleInterval, IStreamingConsumer consumer)
 {
     lock (lockConsumersBySymbol) {
         if (this.DistributionChannels.ContainsKey(symbol) == false)
         {
             SymbolScaleDistributionChannel newChannel = new SymbolScaleDistributionChannel(symbol, scaleInterval);
             newChannel.ConsumersQuoteAdd(consumer);
             Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> newScaleChannels = new Dictionary <BarScaleInterval, SymbolScaleDistributionChannel>();
             newScaleChannels.Add(scaleInterval, newChannel);
             this.DistributionChannels.Add(symbol, newScaleChannels);
             if (this.StreamingProvider.UpstreamIsSubscribed(symbol) == false)
             {
                 this.StreamingProvider.UpstreamSubscribe(symbol);
             }
             return;
         }
         Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> channels = this.DistributionChannels[symbol];
         if (channels.ContainsKey(scaleInterval) == false)
         {
             SymbolScaleDistributionChannel newChannel = new SymbolScaleDistributionChannel(symbol, scaleInterval);
             newChannel.ConsumersQuoteAdd(consumer);
             channels.Add(scaleInterval, newChannel);
             return;
         }
         SymbolScaleDistributionChannel channel = channels[scaleInterval];
         if (channel.ConsumersQuoteContains(consumer) == false)
         {
             channel.ConsumersQuoteAdd(consumer);
             return;
         }
         Assembler.PopupException("QuoteConsumer [" + consumer + "] already registered for [" + channel + "]; returning");
     }
 }
Esempio n. 3
0
 public void ConsumerQuoteUnRegister(string symbol, BarScaleInterval scaleInterval, IStreamingConsumer consumer)
 {
     lock (lockConsumersBySymbol) {
         if (this.DistributionChannels.ContainsKey(symbol) == false)
         {
             Assembler.PopupException("Can't unregister QuoteConsumer [" + consumer + "]: symbol[" + symbol + "] is not registered for any consumers; returning");
             return;
         }
         Dictionary <BarScaleInterval, SymbolScaleDistributionChannel> channels = this.DistributionChannels[symbol];
         if (channels.ContainsKey(scaleInterval) == false)
         {
             string symbolDistributorsAsString = "";
             foreach (SymbolScaleDistributionChannel d in channels.Values)
             {
                 symbolDistributorsAsString += d + ",";
             }
             symbolDistributorsAsString.TrimEnd(',');
             Assembler.PopupException("Can't unregister QuoteConsumer [" + consumer + "]: scaleInterval[" + scaleInterval + "] not found among distributors [" + symbolDistributorsAsString + "]; returning");
             return;
         }
         SymbolScaleDistributionChannel channel = channels[scaleInterval];
         if (channel.ConsumersQuoteContains(consumer) == false)
         {
             Assembler.PopupException("Can't unregister QuoteConsumer [" + consumer + "]: consumer not found in [" + channel.ConsumersQuoteAsString + "]; returning");
             return;
         }
         channel.ConsumersQuoteRemove(consumer);
         if (channel.ConsumersBarCount == 0 && channel.ConsumersQuoteCount == 0)
         {
             //Assembler.PopupException("QuoteConsumer [" + consumer + "] was the last one using [" + symbol + "][" + scaleInterval + "]; removing QuoteBarDistributor[" + channel + "]");
             channels.Remove(scaleInterval);
             if (channels.Count == 0)
             {
                 //Assembler.PopupException("QuoteConsumer [" + scaleInterval + "] was the last one listening for [" + symbol + "]");
                 //Assembler.PopupException("...removing[" + symbol + "] from this.DistributionChannels[" + this.DistributionChannels + "]");
                 this.DistributionChannels.Remove(symbol);
                 //Assembler.PopupException("...UpstreamUnSubscribing [" + symbol + "]");
                 this.StreamingProvider.UpstreamUnSubscribe(symbol);
             }
         }
     }
 }