Exemple #1
0
        private void Level1Update(MessageMbtQuotes message)
        {
            SymbolHandler handler;

            try
            {
                SymbolInfo symbolInfo = Factory.Symbol.LookupSymbol(message.Symbol);
                handler = symbolHandlers[symbolInfo.BinaryIdentifier];
            }
            catch (ApplicationException)
            {
                log.Info("Received tick: " + new string(message.DataIn.ReadChars(message.Remaining)));
                throw;
            }
            if (message.Bid != 0)
            {
                handler.Bid = message.Bid;
            }
            if (message.Ask != 0)
            {
                handler.Ask = message.Ask;
            }
            if (message.AskSize != 0)
            {
                handler.AskSize = message.AskSize;
            }
            if (message.BidSize != 0)
            {
                handler.BidSize = message.BidSize;
            }
            UpdateTime(handler, message);
            handler.SendQuote();
            return;
        }
Exemple #2
0
        private void UpdateTime(SymbolHandler handler, MessageMbtQuotes message)
        {
            TimeStamp currentTime;

            if (UseLocalTickTime)
            {
                currentTime = TimeStamp.UtcNow;
            }
            else
            {
                currentTime = new TimeStamp(message.GetTickUtcTime());
            }
            if (currentTime <= handler.Time)
            {
                currentTime.Internal = handler.Time.Internal + 1;
            }
            handler.Time = currentTime;
        }
Exemple #3
0
        private void OptionChainUpdate(MessageMbtQuotes message)
        {
            var symbol     = message.Symbol;
            var symbolInfo = Factory.Symbol.LookupSymbol(symbol);
            var handler    = symbolOptionHandlers[symbolInfo.BinaryIdentifier];

            if (message.Bid != 0)
            {
                handler.Bid = message.Bid;
            }
            if (message.Ask != 0)
            {
                handler.Ask = message.Ask;
            }
            if (message.AskSize != 0)
            {
                handler.AskSize = message.AskSize;
            }
            if (message.BidSize != 0)
            {
                handler.BidSize = message.BidSize;
            }
            if (message.Last != 0)
            {
                handler.Last = message.Last;
            }
            if (message.LastSize != 0)
            {
                handler.LastSize = message.LastSize;
            }
            if (message.Strike != 0)
            {
                handler.StrikePrice = message.Strike;
            }
            handler.OptionType          = message.OptionType;
            handler.UtcOptionExpiration = new TimeStamp(message.UtcOptionExpiration);
            UpdateTime(handler, message);
            handler.SendOptionPrice();
            handler.Clear();
            return;
        }
Exemple #4
0
        protected void ReceiveMessage(MessageMbtQuotes message)
        {
            switch (message.MessageType)
            {
            case '1':
                Level1Update(message);
                break;

            case '2':
                log.Error("Message type '2' unknown Message is: " + message);
                log.Info("Received tick: " + new string(message.DataIn.ReadChars(message.Remaining)));
                break;

            case '3':
                if (trace)
                {
                    message.Data.Position = 0;
                    var messageText = new string(message.DataIn.ReadChars(message.Remaining));
                    log.Trace("Received tick: " + messageText);
                }
                // Filter Form T trades which are belatedly entered at the last close price
                // later on the next day with sales type 30031 or condition 29.
                // Also eliminate condition 53 which is an average trade price for the day.
                if (message.SalesType != 30031 && message.Condition != 29 && message.Condition != 53)
                {
                    TimeAndSalesUpdate(message);
                }
                break;

            case '4':
                OptionChainUpdate(message);
                break;

            default:
                var messageInError = new string(message.DataIn.ReadChars(message.Remaining));
                log.Info("Received tick: " + messageInError);
                throw new ApplicationException("MBTQuotes message type '" + message.MessageType + "' was unknown: \n" + messageInError);
            }
        }
Exemple #5
0
        private void TimeAndSalesUpdate(MessageMbtQuotes message)
        {
            var symbol     = message.Symbol;
            var symbolInfo = Factory.Symbol.LookupSymbol(symbol);
            var handler    = symbolHandlers[symbolInfo.BinaryIdentifier];

            handler.Last = message.Last;
            if (trace)
            {
                log.Trace("Got last trade price: " + handler.Last);                 // + "\n" + Message);
            }
            handler.LastSize = message.LastSize;
            int condition = message.Condition;

            if (condition != 0 &&
                condition != 53 &&
                condition != 45)
            {
                log.Info("Trade quote received with non-zero condition: " + condition);
            }
            int status = message.Status;

            if (status != 0)
            {
                log.Info("Trade quote received with non-zero status: " + status);
            }
            int type = message.Type;

            if (type != 0)
            {
                log.Info("Trade quote received with non-zero type: " + type);
            }
            UpdateTime(handler, message);
            handler.SendTimeAndSales();
            return;
        }