private void QuotesLogin(PacketMBTQuotes packet) { if (quoteState != ServerState.Startup) { CloseWithQuotesError(packet, "Invalid login request. Already logged in."); } quoteState = ServerState.LoggedIn; var writePacket = quoteSocket.CreatePacket(); string message = "G|100=DEMOXJSP;8055=demo01\n"; if (debug) { log.Debug("Login response: " + message); } writePacket.DataOut.Write(message.ToCharArray()); quotePacketQueue.Enqueue(writePacket); }
private void CloseWithQuotesError(PacketMBTQuotes packet, string message) { }
private unsafe Yield SymbolRequest(PacketMBTQuotes packet) { var data = packet.Data; data.Position += 2; SymbolInfo symbolInfo = null; fixed(byte *bptr = data.GetBuffer()) { byte *ptr = bptr + data.Position; while (ptr - bptr < data.Length) { int key = packet.GetKey(ref ptr); switch (key) { case 1003: // Symbol var symbol = packet.GetString(ref ptr); symbolInfo = Factory.Symbol.LookupSymbol(symbol); log.Info("Received symbol request for " + symbolInfo); AddSymbol(symbol, OnHeartbeat, OnTick, OnPhysicalFill, OnRejectOrder); break; case 2000: // Type of data. var feedType = packet.GetString(ref ptr); switch (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; } break; } } } return(Yield.DidWork.Repeat); }