private void OnMessage(QuickFix.FIX42.MarketDataRequest m, SessionID s) { QuickFix.FIX42.MarketDataRequest.NoRelatedSymGroup symbolGroup = new QuickFix.FIX42.MarketDataRequest.NoRelatedSymGroup(); m.GetGroup(1, symbolGroup); string symbolName = symbolGroup.Get(new Symbol()).getValue(); string mdRequestId = m.MDReqID.ToString(); if (!m_ProductSubscription.ContainsKey(symbolName)) { bool fullSpeed = symbolName.StartsWith("B"); Console.WriteLine("Subscribe : " + symbolName + ". Full Speed: " + fullSpeed); QuotePublisher publisher = new QuotePublisher(symbolName, mdRequestId, fullSpeed, s); m_ProductSubscription.Add(symbolName, publisher); } }
//receive responses from position request messages //public void onPositionReportMessage(QuickFix.FIX42.Message message, SessionID session) //{ // TT.PosReqId req = new TT.PosReqId(); // string r = message.GetField(req).getValue(); //SOD, DSOD, MANUAL_FILL, TRADES // log.WriteLog(r); // TT.TotalNumPosReports num = new TT.TotalNumPosReports(); // int numReports = message.GetField(num).getValue() ; // log.WriteLog(numReports.ToString()); // TT.PosMaintRptId uniqueID = new TT.PosMaintRptId(); // if (posReports.Contains(message.GetField(uniqueID).getValue())) // { updateDisplay("Duplicate position report recieved and discarded: " + uniqueID.ToString()); } // else // { // posReports.Add(message.GetField(uniqueID).getValue()); // if (message.IsSetField(num) && numReports != 0) // { // updateDisplay(string.Format("{0} updates in this {1} report",num, r)); // posTableUpdate(message, session); // } // else // { updateDisplay(string.Format("No Updates in this {0} position report", r)); } // switch (r) // { // case "SOD": // ctrSOD += 1; // if (numReports == 0 || ctrSOD == numReports) { SODLoaded = true; } // break; // case "DSOD": // ctrSOD += 1; // if (numReports == 0 || ctrSOD == numReports) { SODLoaded = true; } // break; // case "MANUAL_FILL": // ctrMAN += 1; // if (numReports == 0 || ctrMAN == numReports) { ManualFillsLoaded = true; } // break; // case "TRADES": // ctrTRD += 1; // if (numReports == 0 || ctrTRD == numReports) { previousTradesLoaded = true; } // break; // default: // break; // } // log.WriteLog("SOD Loaded: " + SODLoaded.ToString()); // log.WriteLog("MAN Loaded: " + ManualFillsLoaded.ToString()); // log.WriteLog("TRD Loaded: " + previousTradesLoaded.ToString()); // if (SODLoaded && ManualFillsLoaded && previousTradesLoaded && !PositionLoadedReported) // { // updateOnOff(); // updateDisplay("RISK MANUAL FILLS AND TRADES LOADED"); // PositionLoadedReported = true; // } // } //} public void OnMessage(QuickFix.FIX42.GatewayStatus message, SessionID session) { QuickFix.Group g = new QuickFix.FIX42.GatewayStatus.NoGatewayStatusGroup(); for (int i = 1; i <= message.GroupCount(message.NoGatewayStatus.getValue()); i++) { message.GetGroup(i, g); string exch = g.GetField(new QuickFix.Fields.ExchangeGateway()).getValue(); int server = g.GetField(new QuickFix.Fields.SubExchangeGateway()).getValue(); int status = g.GetField(new QuickFix.Fields.GatewayStatus()).getValue(); string text = null; try { text = g.GetField(new QuickFix.Fields.Text()).ToString(); updateDisplay(string.Format("Text: {0}", text)); } catch (Exception ex) { updateDisplay(string.Format("NO TEXT:{0}", ex.ToString())); } updateGateway(exch, new QuickFix.Fields.SubExchangeGateway(server).toStringField().ToString(), new QuickFix.Fields.GatewayStatus(status).toStringField().ToString(), text); } }
//Receive market data public void OnMessage(QuickFix.FIX42.MarketDataSnapshotFullRefresh message, SessionID session) { decimal _bidPrice = 0.00M; decimal _askPrice = 0.00M; try { QuickFix.Group noMDEntriesGrp = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); for (int grpIndex = 1; grpIndex <= message.GetInt(QuickFix.Fields.Tags.NoMDEntries); grpIndex += 1) { noMDEntriesGrp = message.GetGroup(grpIndex, QuickFix.Fields.Tags.NoMDEntries); if (noMDEntriesGrp.IsSetField(QuickFix.Fields.Tags.BidPx)) { _bidPrice = QuickFix.Fields.Converters.DecimalConverter.Convert(noMDEntriesGrp.GetField(QuickFix.Fields.Tags.BidPx)); } if (noMDEntriesGrp.IsSetField(QuickFix.Fields.Tags.OfferPx)) { _askPrice = QuickFix.Fields.Converters.DecimalConverter.Convert(noMDEntriesGrp.GetField(QuickFix.Fields.Tags.OfferPx)); } } string SecEx = null; string symbol = null; string secID = null; QuickFix.Fields.SecurityExchange se = new QuickFix.Fields.SecurityExchange(); if (message.IsSetField(se)) { SecEx = message.GetField(se).ToString(); } QuickFix.Fields.Symbol s = new QuickFix.Fields.Symbol(); if (message.IsSetField(s)) { symbol = message.GetField(s).ToString(); } QuickFix.Fields.SecurityID sid = new QuickFix.Fields.SecurityID(); if (message.IsSetField(sid)) { secID = message.GetField(sid).ToString(); } updatePrices(SecEx, symbol, secID, _bidPrice, _askPrice); } catch (Exception ex) { updateDisplay(string.Format("QuickFIX Error: {0}", System.Reflection.MethodBase.GetCurrentMethod().Name)); log.WriteLog(string.Format("{0} : {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString())); } }