//shows example of parsing a standard QuickFix group public override void onMessage(QuickFix42.MarketDataSnapshotFullRefresh message, SessionID session) { parseMessage(message, session); if (message.hasGroup(new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries())) { QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries g = new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries(); updateDisplay(string.Format("Found {0} NoMDEntries groups", message.groupCount(QuickFix.NoMDEntries.FIELD))); QuickFix.NoMDEntries nEntries = new QuickFix.NoMDEntries(); message.getField(nEntries); for (uint i = 1; i <= message.groupCount(QuickFix.NoMDEntries.FIELD); i++) { message.getGroup(i, g); updateDisplay(string.Format("mdEntryType: {0}", g.get(new QuickFix.MDEntryType()))); updateDisplay(string.Format("mdEntryPx: {0}", g.get(new QuickFix.MDEntryPx()))); updateDisplay(string.Format("mdEntrySize: {0}", g.get(new QuickFix.MDEntrySize()))); if (g.get(new QuickFix.MDEntryType()).getValue() == QuickFix.MDEntryType.BID) { //string s = g.get(new QuickFix.MDEntryPx()).ToString(); _bidPrice = Convert.ToDouble(g.get(new QuickFix.MDEntryPx()).getValue()); } if (g.get(new QuickFix.MDEntryType()).getValue() == QuickFix.MDEntryType.OFFER) { string s = g.get(new QuickFix.MDEntryPx()).ToString(); _askPrice = Convert.ToDouble(s); } } } updateFormData(); }
public override void onMessage(QuickFix42.MarketDataSnapshotFullRefresh snapshot, QuickFix.SessionID sessionID) { if (snapshot.isSetNoMDEntries()) { string reqID = snapshot.getMDReqID().getValue(); Instrument instrument = (provider as GSFIX).GetInstrument(reqID); instrument.OrderBook.Clear(); QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries(); Quote quote = new Quote(); quote.DateTime = Clock.Now; for (uint i = 1; i <= snapshot.getNoMDEntries().getValue(); i++) { snapshot.getGroup(i, group); SmartQuant.Data.MarketDepth depth; int position = 0; if (group.isSetMDEntryPositionNo()) { position = group.getMDEntryPositionNo().getValue() - 1; } double price = group.getMDEntryPx().getValue(); int size = (int)group.getMDEntrySize().getValue(); // Console.WriteLine("Snapshot Level : " + position + " " + price + " " + size); switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.TRADE: provider.EmitTrade(new Trade(Clock.Now, price, size), instrument); break; case QuickFix.MDEntryType.BID: // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Insert, MDSide.Bid, price, size); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { quote.Bid = price; quote.BidSize = size; } break; case QuickFix.MDEntryType.OFFER: // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Insert, MDSide.Ask, price, size); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { quote.Ask = price; quote.AskSize = size; } break; } } group.Dispose(); provider.EmitQuote(quote, instrument); } }