Beispiel #1
0
        public virtual void PushQuoteReceived(Quote quote)
        {
            if (quote.ServerTime == DateTime.MinValue)
            {
                quote.ServerTime = this.DataSource.MarketInfo.ConvertLocalTimeToServer(DateTime.Now);
            }

            MarketInfo marketInfo = this.DataSource.MarketInfo;

            //if (marketInfo.IsMarketOpenNow == false) {
            if (marketInfo.IsMarketOpenAtServerTime(quote.ServerTime) == false)
            {
                MarketClearingTimespan clearingTimespanOut;
                DateTime dateTimeNextBarOpenConditional = marketInfo.GetNextMarketServerTimeStamp(
                    quote.ServerTime, this.DataSource.ScaleInterval, out clearingTimespanOut);
                string reason = (clearingTimespanOut != null) ? "is CLEARING" : "CLOSED";
                string msg    = "[" + marketInfo.Name + "]Market " + reason + ", resumes["
                                + dateTimeNextBarOpenConditional.ToString("HH:mm") + "]; ignoring quote[" + quote + "]";
                this.UpdateConnectionStatus(503, msg);
                return;
            }
            else
            {
                int a = 1;
            }

            Quote lastQuote = this.StreamingDataSnapshot.LastQuoteGetForSymbol(quote.Symbol);

            if (lastQuote == null)
            {
                string msg = "RECEIVED_FIRST_QUOTE_EVER_FOR symbol[" + quote.Symbol + "]";
                //Assembler.PopupException(msg);
                //throw new Exception(msg);
            }
            else
            {
                //LESS PRECISE, HAS NO MILLISECONDS FROM QUIK if (quote.ServerTime > lastQuote.ServerTime) {
                if (quote.ServerTime.Ticks > lastQuote.ServerTime.Ticks)
                {
                    //if (quote.IntraBarSerno < Quote.IntraBarSernoShiftForGeneratedTowardsPendingFill) {
                    //    quote.IntraBarSerno = lastQuote.IntraBarSerno + 1;
                    //    if (quote.IntraBarSerno > Quote.IntraBarSernoShiftForGeneratedTowardsPendingFill) {
                    //        string msg = "#3 bro, leave QUOTE unmodified!!!";
                    //        Debugger.Break();
                    //    }
                    //}
                }
                else
                {
                    Assembler.PopupException("WEIRD: upcoming quote.LocalTimeCreatedMillis[" + quote.LocalTimeCreatedMillis.ToString("HH:mm:ss.fff")
                                             + "] <= lastQuoteReceived.Symbol." + quote.Symbol + "["
                                             + lastQuote.LocalTimeCreatedMillis.ToString("HH:mm:ss.fff") + "]: DDE lagged somewhere?...");
                }
                quote.Absno = lastQuote.Absno + 1;
            }

            this.EnrichQuoteWithStreamingDependantDataSnapshot(quote);

            //BacktestStreamingProvider.EnrichGeneratedQuoteSaveSpreadInStreaming has updated lastQuote alredy...
            this.StreamingDataSnapshot.UpdateLastBidAskSnapFromQuote(quote);
            try {
                this.DataDistributor.PushQuoteToChannel(quote);
            } catch (Exception e) {
                string msg = "StreamingProvider.PushReceivedQuote()";
                Assembler.PopupException(msg, e);
                //throw e;
            }
        }