public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh msg, SessionID s) { _seen.Add(msg.Symbol.getValue()); if (msg.Symbol.getValue() == DebugSymbol) { for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var item = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, item); Console.WriteLine($"Received MarketDataSnapshotFullRefresh for {msg.Symbol.getValue()} with {msg.NoMDEntries.getValue()} items (lag: {(DateTime.UtcNow - msg.Header.GetDateTime(52)).TotalMilliseconds} / {(DateTime.UtcNow - item.MDEntryDate.getValue().Add(item.MDEntryTime.getValue().TimeOfDay)).TotalMilliseconds})."); break; } } return; //for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) //{ // var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); // msg.GetGroup(idx + 1, level); // Console.WriteLine($"{level.MDEntryType} @ {msg.Symbol}:"); // Console.WriteLine($" Date: {level.MDEntryDate}"); // Console.WriteLine($" Time: {level.MDEntryTime}"); // Console.WriteLine($" Px: {level.MDEntryPx}"); // Console.WriteLine($" Size: {level.MDEntrySize}"); //} Console.WriteLine("BIDS:"); for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, level); if (level.MDEntryType.getValue() == MDEntryType.OFFER) { continue; } Console.WriteLine($"P {level.MDEntryPx} @ S {level.MDEntrySize}"); } Console.WriteLine("ASKS:"); for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, level); if (level.MDEntryType.getValue() == MDEntryType.BID) { continue; } Console.WriteLine($"P {level.MDEntryPx} @ S {level.MDEntrySize}"); } }
/// <summary> /// Initial market data snapshot /// </summary> /// <param name="msg"></param> /// <param name="sessionID"></param> public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh msg, SessionID sessionID) { var numMDEntries = msg.GetInt(Tags.NoMDEntries); for (int i = 1; i <= numMDEntries; i++) { var entry = msg.GetGroup(i, Tags.NoMDEntries); var entryType = entry.GetChar(Tags.MDEntryType); if (entryType.Equals(MDEntryType.BID) || entryType.Equals(MDEntryType.OFFER)) { CurrentOrderBook.AddOrder((double)entry.GetDecimal(Tags.MDEntryPx), (double)entry.GetDecimal(Tags.MDEntrySize), entry.GetChar(Tags.MDEntryType)); } else if (entryType.Equals(MDEntryType.TRADE)) { LastTrade = new Trade() { Price = (double)entry.GetDecimal(Tags.MDEntryPx), Volume = (double)entry.GetDecimal(Tags.MDEntrySize) }; } else { Log.Write($"Unknown entry type {entryType}", 0); } } }
public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh msg, SessionID s) { Console.WriteLine($"Received MarketDataSnapshotFullRefresh for {msg.Symbol.getValue()} with {msg.NoMDEntries.getValue()} items."); //for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) //{ // var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); // msg.GetGroup(idx + 1, level); // Console.WriteLine($"{level.MDEntryType} @ {msg.Symbol}:"); // Console.WriteLine($" Date: {level.MDEntryDate}"); // Console.WriteLine($" Time: {level.MDEntryTime}"); // Console.WriteLine($" Px: {level.MDEntryPx}"); // Console.WriteLine($" Size: {level.MDEntrySize}"); //} Console.WriteLine("BIDS:"); for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, level); if (level.MDEntryType.getValue() == MDEntryType.OFFER) { continue; } Console.WriteLine($"P {level.MDEntryPx} @ S {level.MDEntrySize}"); } Console.WriteLine("ASKS:"); for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, level); if (level.MDEntryType.getValue() == MDEntryType.BID) { continue; } Console.WriteLine($"P {level.MDEntryPx} @ S {level.MDEntrySize}"); } }
public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh msg, SessionID s) { for (int idx = 0; idx < msg.NoMDEntries.getValue(); idx++) { var level = new QuickFix.FIX44.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); msg.GetGroup(idx + 1, level); Console.WriteLine($"Orderbook {level.MDEntryType} @ {msg.Symbol}:"); Console.WriteLine($" Date: {level.MDEntryDate}"); Console.WriteLine($" Time: {level.MDEntryTime}"); Console.WriteLine($" Px: {level.MDEntryPx}"); Console.WriteLine($" Size: {level.MDEntrySize}"); } }
public void DateOnlyTimeOnlyConvertProblem() { // issue 135 var dd = new QuickFix.DataDictionary.DataDictionary(); dd.Load("../../../spec/fix/FIX44.xml"); string[] msgFields = { "8=FIX.4.4", "9=332", "35=W", "34=2", "49=MA", "52=20121024-12:21:42.170", "56=xxxx", "22=4", "48=BE0932900518", "55=[N/A]", "262=1b145288-9c9a-4911-a084-7341c69d3e6b", "762=EURO_EUR", "268=2", "269=0", "270=97.625", "15=EUR", "271=1246000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15478575", "269=1", "270=108.08", "15=EUR", "271=884000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15467902", "10=77" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new QuickFix.FIX44.MarketDataSnapshotFullRefresh(); msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup gentry1 = (QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup)msg.GetGroup(1, new QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup()); Assert.AreEqual(new DateTime(2012, 10, 24), gentry1.MDEntryDate.getValue()); Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47).TimeOfDay, gentry1.MDEntryTime.getValue().TimeOfDay); Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47), gentry1.MDEntryDate.getValue() + gentry1.MDEntryTime.getValue().TimeOfDay); }
public void DateOnlyTimeOnlyConvertProblem() { // issue 135 var dd = new QuickFix.DataDictionary.DataDictionary(); dd.Load("../../../spec/fix/FIX44.xml"); string[] msgFields = { "8=FIX.4.4", "9=332", "35=W", "34=2", "49=MA", "52=20121024-12:21:42.170", "56=xxxx", "22=4", "48=BE0932900518", "55=[N/A]", "262=1b145288-9c9a-4911-a084-7341c69d3e6b", "762=EURO_EUR", "268=2", "269=0", "270=97.625", "15=EUR", "271=1246000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15478575", "269=1", "270=108.08", "15=EUR", "271=884000", "272=20121024", "273=07:30:47", "276=I", "282=BEARGB21XXX", "299=15467902", "10=77" }; string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH; QuickFix.FIX44.MarketDataSnapshotFullRefresh msg = new QuickFix.FIX44.MarketDataSnapshotFullRefresh(); msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup gentry1 = new QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup(); msg.GetGroup(1, gentry1); Assert.AreEqual(new DateTime(2012, 10, 24), gentry1.MDEntryDate.getValue()); Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47).TimeOfDay, gentry1.MDEntryTime.getValue().TimeOfDay); Assert.AreEqual(new DateTime(2012, 10, 24, 7, 30, 47), gentry1.MDEntryDate.getValue() + gentry1.MDEntryTime.getValue().TimeOfDay); }
public void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh m, SessionID s) { string symbol = m.GetString(Tags.Symbol).ToString(); double bid_price = 0; double ask_price = 0; int entry_count = int.Parse(m.GetString(Tags.NoMDEntries)); for (int i = 1; i <= entry_count; i++) { QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup group = new QuickFix.FIX44.MarketDataIncrementalRefresh.NoMDEntriesGroup(); m.GetGroup(i, group); string entry_type = group.GetString(Tags.MDEntryType); if (entry_type == "0") { bid_price = double.Parse(group.GetString(Tags.MDEntryPx)); } else if (entry_type == "1") { ask_price = double.Parse(group.GetString(Tags.MDEntryPx)); } } Console.WriteLine("Symbol: " + symbol + " Bid: " + bid_price.ToString() + " Ask: " + ask_price.ToString()); }
/// <summary> /// /// </summary> /// <param name="message">Market data snapshot full refresh message</param> /// <param name="session">Session ID</param> private void OnMessage(QuickFix.FIX44.MarketDataSnapshotFullRefresh message, QuickFix.SessionID session) { try { int numberOfMarketDataEntries = message.NoMDEntries.getValue(); for (int i = 1; i <= numberOfMarketDataEntries; i++) { Tick tick = new Tick(new Security() { Symbol = message.Symbol.getValue() }, _provider); tick.DateTime = message.Header.GetDateTime(QuickFix.Fields.Tags.SendingTime); QuickFix.Group group = message.GetGroup(i, QuickFix.Fields.Tags.NoMDEntries); if (group.GetField(QuickFix.Fields.Tags.MDEntryType).Equals("0")) { tick.BidPrice = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntryPx)); tick.BidSize = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntrySize)); } if (group.GetField(QuickFix.Fields.Tags.MDEntryType).Equals("1")) { tick.AskPrice = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntryPx)); tick.AskSize = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntrySize)); } if (TickArrived != null) { TickArrived(tick); } } } catch (Exception exception) { Logger.Error(exception.ToString(), _type.FullName, "OnMessage"); } }