public override void onMessage(QuickFix42.MarketDataIncrementalRefresh refresh, QuickFix.SessionID sessionID) { if (refresh.isSetNoMDEntries()) { string reqID = refresh.getMDReqID().getValue(); Instrument instrument = (provider as GSFIX).GetInstrument(reqID); if (instrument == null) { return; } QuickFix42.MarketDataIncrementalRefresh.NoMDEntries group = new QuickFix42.MarketDataIncrementalRefresh.NoMDEntries(); int position; double price; int size; SmartQuant.Data.MarketDepth depth; SmartQuant.Data.Quote quote; for (uint i = 1; i <= refresh.getNoMDEntries().getValue(); i++) { refresh.getGroup(i, group); switch (group.getMDUpdateAction().getValue()) { // new case QuickFix.MDUpdateAction.NEW: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("NEW BID"); price = group.getMDEntryPx().getValue(); size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Bid, price, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (price > instrument.Quote.Bid) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.Bid = price; quote.BidSize = size; provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("NEW ASK"); price = group.getMDEntryPx().getValue(); size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Ask, price, size); provider.EmitMarketDepth(depth, instrument); // quote, best ask if (price < instrument.Quote.Ask) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.Ask = price; quote.AskSize = size; provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.TRADE: provider.EmitTrade(new Trade(Clock.Now, group.getMDEntryPx().getValue(), (int)group.getMDEntrySize().getValue()), instrument); break; } } break; // change case QuickFix.MDUpdateAction.CHANGE: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("CHANGE BID!"); position = group.getMDEntryPositionNo().getValue() - 1; size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Bid, 0, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (position == 0) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.BidSize = (int)group.getMDEntrySize().getValue(); provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("CHANGE ASK!"); position = group.getMDEntryPositionNo().getValue() - 1; size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Ask, 0, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (position == 0) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.AskSize = (int)group.getMDEntrySize().getValue(); provider.EmitQuote(quote, instrument); } break; } } break; // delete case QuickFix.MDUpdateAction.DELETE: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("DELETE BID"); position = group.getMDEntryPositionNo().getValue() - 1; // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Bid, 0, 0); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { Quote newQuote = instrument.OrderBook.GetQuote(0); newQuote.DateTime = Clock.Now; provider.EmitQuote(newQuote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("DELETE ASK"); position = group.getMDEntryPositionNo().getValue() - 1; // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Ask, 0, 0); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { Quote newQuote = instrument.OrderBook.GetQuote(0); newQuote.DateTime = Clock.Now; provider.EmitQuote(newQuote, instrument); } break; } } break; } } group.Dispose(); } }
public override void onMessage(QuickFix42.MarketDataIncrementalRefresh refresh, QuickFix.SessionID sessionID) { if (refresh.isSetNoMDEntries()) { string reqID = refresh.getMDReqID().getValue(); Instrument instrument = (provider as GSFIX).GetInstrument(reqID); if (instrument == null) return; QuickFix42.MarketDataIncrementalRefresh.NoMDEntries group = new QuickFix42.MarketDataIncrementalRefresh.NoMDEntries(); int position; double price; int size; SmartQuant.Data.MarketDepth depth; SmartQuant.Data.Quote quote; for (uint i = 1; i <= refresh.getNoMDEntries().getValue(); i++) { refresh.getGroup(i, group); switch (group.getMDUpdateAction().getValue()) { // new case QuickFix.MDUpdateAction.NEW: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("NEW BID"); price = group.getMDEntryPx().getValue(); size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Bid, price, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (price > instrument.Quote.Bid) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.Bid = price; quote.BidSize = size; provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("NEW ASK"); price = group.getMDEntryPx().getValue(); size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Ask, price, size); provider.EmitMarketDepth(depth, instrument); // quote, best ask if (price < instrument.Quote.Ask) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.Ask = price; quote.AskSize = size; provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.TRADE: provider.EmitTrade(new Trade(Clock.Now, group.getMDEntryPx().getValue(), (int)group.getMDEntrySize().getValue()), instrument); break; } } break; // change case QuickFix.MDUpdateAction.CHANGE: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("CHANGE BID!"); position = group.getMDEntryPositionNo().getValue() - 1; size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Bid, 0, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (position == 0) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.BidSize = (int)group.getMDEntrySize().getValue(); provider.EmitQuote(quote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("CHANGE ASK!"); position = group.getMDEntryPositionNo().getValue() - 1; size = (int)group.getMDEntrySize().getValue(); // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Ask, 0, size); provider.EmitMarketDepth(depth, instrument); // quote, best bid if (position == 0) { quote = new Quote(instrument.Quote); quote.DateTime = Clock.Now; quote.AskSize = (int)group.getMDEntrySize().getValue(); provider.EmitQuote(quote, instrument); } break; } } break; // delete case QuickFix.MDUpdateAction.DELETE: { switch (group.getMDEntryType().getValue()) { case QuickFix.MDEntryType.BID: //Console.WriteLine("DELETE BID"); position = group.getMDEntryPositionNo().getValue() - 1; // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Bid, 0, 0); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { Quote newQuote = instrument.OrderBook.GetQuote(0); newQuote.DateTime = Clock.Now; provider.EmitQuote(newQuote, instrument); } break; case QuickFix.MDEntryType.OFFER: //Console.WriteLine("DELETE ASK"); position = group.getMDEntryPositionNo().getValue() - 1; // market depth depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Ask, 0, 0); provider.EmitMarketDepth(depth, instrument); // quote if (position == 0) { Quote newQuote = instrument.OrderBook.GetQuote(0); newQuote.DateTime = Clock.Now; provider.EmitQuote(newQuote, instrument); } break; } } break; } } group.Dispose(); } }
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); } }
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); } }