Ejemplo n.º 1
0
        private unsafe void BookRebuild(LimeQuoteMessage message)
        {
            //UNDONE: Use the symbol_len field from the message and the action to filter
            LimeQuotesInterop.book_rebuild_msg *bookMsg = (LimeQuotesInterop.book_rebuild_msg *)message.Ptr;
            int last = 0;

            for (int i = 0; i < LimeQuotesInterop.SYMBOL_LEN; i++)
            {
                if (bookMsg->symbol[i] == 0)
                {
                    last = i;
                    break;
                }
            }
            string symbol = new string((sbyte *)bookMsg->symbol, 0, last);

            log.InfoFormat("Book Rebuild for {0} id {1} flags {2}", symbol, bookMsg->symbol_index, bookMsg->symbol_flags);

            using (_SymbolIDLock.Using())
            {
                uint id = Reverse(bookMsg->symbol_index);
                if (!_SymbolID.ContainsKey(symbol))
                {
                    _SymbolID.Add(symbol, id);
                    _IDToSymbol.Add(id, symbol);
                    _IDToBookRebuild.Add(id, (bookMsg->symbol_flags & 1) == 0);
                }
                else
                {
                    _SymbolID[symbol]    = id;
                    _IDToSymbol[id]      = symbol;
                    _IDToBookRebuild[id] = (bookMsg->symbol_flags & 1) == 0;
                }
            }
        }
Ejemplo n.º 2
0
        private unsafe void SymbolRequest(LimeQuoteMessage message)
        {
            LimeQuotesInterop.subscription_request_msg *subRequest = (LimeQuotesInterop.subscription_request_msg *)message.Ptr;
            String symbol = "";

            for (int i = 0; subRequest->syb_symbols[i] != 0; i++)
            {
                symbol += (char)subRequest->syb_symbols[i];
            }

            var symbolInfo = Factory.Symbol.LookupSymbol(symbol);

            log.Info("Lime: Received symbol request for " + symbolInfo);

            ProviderSimulator.AddSymbol(symbolInfo.Symbol);

            var writePacket = (LimeQuoteMessage)QuoteSocket.MessageFactory.Create();

            LimeQuotesInterop.subscription_reply_msg *reply = (LimeQuotesInterop.subscription_reply_msg *)writePacket.Ptr;
            reply->msg_type = LimeQuotesInterop.limeq_message_type.SUBSCRIPTION_REPLY;
            var msg_len = (ushort)sizeof(LimeQuotesInterop.subscription_reply_msg);

            reply->msg_len     = Reverse(msg_len);
            writePacket.Length = msg_len;
            reply->outcome     = LimeQuotesInterop.subscription_outcome.SUBSCRIPTION_SUCCESSFUL;
            for (int i = 0; i < 4; i++)
            {
                reply->qsid[i] = subRequest->qsid[i];
            }

            QuotePacketQueue.Enqueue(writePacket, message.SendUtcTime);


            var bookRebuildMessage = (LimeQuoteMessage)QuoteSocket.MessageFactory.Create();

            LimeQuotesInterop.book_rebuild_msg *book = (LimeQuotesInterop.book_rebuild_msg *)bookRebuildMessage.Ptr;
            book->msg_type            = LimeQuotesInterop.limeq_message_type.BOOK_REBUILD;
            msg_len                   = (ushort)sizeof(LimeQuotesInterop.book_rebuild_msg);
            book->msg_len             = Reverse(msg_len);
            bookRebuildMessage.Length = msg_len;
            book->symbol_index        = (uint)symbolInfo.BinaryIdentifier;
            for (int i = 0; i < symbol.Length; i++)
            {
                book->symbol[i] = (byte)symbol[i];
            }
            QuotePacketQueue.Enqueue(bookRebuildMessage, message.SendUtcTime);
        }