예제 #1
0
        private void bindNewStreamingBarAppendPokeConsumersStaticFormed()
        {
            Bar barStreamingUnattached = StreamingBarFactoryUnattached.StreamingBarUnattached.Clone();

            if (consumersBar.Count == 0)
            {
                Assembler.PopupException("Can't push lastBarFormed[" + barStreamingUnattached + "]: no BarConsumers for SymbolScaleInterval["
                                         + SymbolScaleInterval + "]; returning");
                return;
            }
            int consumerSerno             = 1;
            int streamingSolidifiersPoked = 0;
            int backtestProvidersPoked    = 0;

            foreach (IStreamingConsumer consumer in consumersBar)
            {
                string nth = "#" + (consumerSerno++) + "/" + consumersBar.Count;
                if (consumer is Sq1.Core.Backtesting.BacktestQuoteBarConsumer)
                {
                    backtestProvidersPoked++;
                }
                if (consumer is StreamingSolidifier)
                {
                    streamingSolidifiersPoked++;
                    if (streamingSolidifiersPoked > 1)
                    {
                        string msg = "two streaming charts open with same Symbol/Interval, both with their StreamingSolidifiers subscribed"
                                     + " but StreamingSolidifier Should be subscribed only once per Symbol/Interval, in StreamingProvider?...";
                        continue;
                    }
                }
                if (consumer.ConsumerBarsToAppendInto != null &&
                    consumer.ConsumerBarsToAppendInto.BarStaticLast != null &&
                    consumer.ConsumerBarsToAppendInto.BarStaticLast.DateTimeOpen == barStreamingUnattached.DateTimeOpen)
                {
                    string msg = "we are on 1st ever streaming quote: probably shouln't add it to avoid ALREADY_HAVE exception";
                    continue;
                }

                StreamingEarlyBinder binder = this.earlyBinders[consumer];
                Bar    barLastFormedBound   = binder.BindBarToConsumerBarsAndAppend(barStreamingUnattached);
                string msg1 = "barLastFormedBound[" + barLastFormedBound + "] pushing to " + nth + ": " + consumer
                              //+ " <= barLastFormedUnattached[" + barLastFormedUnattached + "]"
                ;
                //Assembler.PopupException(msg1);
                try {
                    //NOPE_FRESH_STREAMING_CONTAINING_JUST_ONE_QUOTE_I_WILL_POKE_QUOTES_FROM_IT consumer.ConsumeBarLastFormed(barLastFormedBound);
                    consumer.ConsumeBarLastStraticJustFormedWhileStreamingBarWithOneQuoteAlreadyAppended(consumer.ConsumerBarsToAppendInto.BarStaticLast);
                } catch (Exception e) {
                    string msg = "BarConsumer " + nth + ": missed bar [" + barStreamingUnattached + "]: " + consumer;
                    throw new Exception(msg, e);
                }
            }
            if (backtestProvidersPoked == 0 && streamingSolidifiersPoked == 0 &&
                barStreamingUnattached.ScaleInterval == new BarScaleInterval(BarScale.Minute, 1))
            {
                string msg = "this bar wasn't saved in StaticProvider!!!";
                throw new Exception(msg);
            }
        }
예제 #2
0
        void bindStreamingBarForQuoteAndPushQuoteToConsumers(Quote quoteSernoEnrichedWithUnboundStreamingBar)
        {
            if (consumersQuote.Count == 0)
            {
                Assembler.PopupException("Can't push quoteSernoEnriched[" + quoteSernoEnrichedWithUnboundStreamingBar + "]: no QuoteConsumers for symbol["
                                         + Symbol + "] + scaleInterval[" + ScaleInterval + "]; returning");
                return;
            }
            int consumerSerno = 1;

            foreach (IStreamingConsumer consumer in consumersQuote)
            {
                string nth = "#" + (consumerSerno++) + "/" + consumersQuote.Count + ": " + consumer;
                try {
                    StreamingEarlyBinder binder      = this.earlyBinders[consumer];
                    Quote quoteWithStreamingBarBound = binder.BindStreamingBarForQuote(quoteSernoEnrichedWithUnboundStreamingBar);
                    //if (consumer.ConsumerBarsToAppendInto != null) {
                    //	string msg = "quoteSernoEnrichedWithUnboundStreamingBar[" + quoteSernoEnrichedWithUnboundStreamingBar
                    //		+ "] cloned quoteWithStreamingBarBound[" + quoteWithStreamingBarBound + "]; pushing to " + nth;
                    //	log.Debug(msg);
                    //}
                    consumer.ConsumeQuoteOfStreamingBar(quoteWithStreamingBarBound);
                } catch (Exception ex) {
                    string msg = "QuoteConsumer " + nth + ": missed quoteSernoEnrichedWithUnboundStreamingBar["
                                 + quoteSernoEnrichedWithUnboundStreamingBar + "] ";
                    Assembler.PopupException(msg, ex);
                }
            }
        }