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); }
private void SymbolRequest(MessageMbtQuotes message) { var symbolInfo = Factory.Symbol.LookupSymbol(message.Symbol); log.Info("Received symbol request for " + symbolInfo); ProviderSimulator.AddSymbol(symbolInfo.Symbol); switch (message.FeedType) { case "20000": // Level 1 if (symbolInfo.QuoteType != QuoteType.Level1) { throw new ApplicationException("Requested data feed of Level1 but Symbol.QuoteType is " + symbolInfo.QuoteType); } break; case "20001": // Level 2 if (symbolInfo.QuoteType != QuoteType.Level2) { throw new ApplicationException("Requested data feed of Level2 but Symbol.QuoteType is " + symbolInfo.QuoteType); } break; case "20002": // Level 1 & Level 2 if (symbolInfo.QuoteType != QuoteType.Level2) { throw new ApplicationException("Requested data feed of Level1 and Level2 but Symbol.QuoteType is " + symbolInfo.QuoteType); } break; case "20003": // Trades if (symbolInfo.TimeAndSales != TimeAndSales.ActualTrades) { throw new ApplicationException("Requested data feed of Trades but Symbol.TimeAndSale is " + symbolInfo.TimeAndSales); } break; case "20004": // Option Chains break; default: throw new ApplicationException("Sorry, unknown data type: " + message.FeedType); } }