private void InitializeQuote(string symbolName, string marketDataRequestId) { m_Quote = new QuickFix.FIX42.MarketDataSnapshotFullRefresh(); m_Quote.SetField(new MDReqID(marketDataRequestId)); m_Quote.SetField(new SecurityExchange("*")); m_Quote.SetField(new TotalVolumeTraded(10000)); m_Quote.SetField(new Symbol(symbolName)); m_Quote.SetField(new NoMDEntries(3)); QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup group1 = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); group1.SetField(new MDEntryType(MDEntryType.BID)); group1.SetField(new MDEntryPx(50m)); group1.SetField(new MDEntrySize(100)); m_Quote.AddGroup(group1); QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup group2 = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); group2.SetField(new MDEntryType(MDEntryType.OFFER)); group2.SetField(new MDEntryPx(50.01m)); group2.SetField(new MDEntrySize(100)); m_Quote.AddGroup(group2); QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup trade = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); trade.SetField(new MDEntryType(MDEntryType.TRADE)); trade.SetField(new MDEntryPx(50.01m)); trade.SetField(new MDEntrySize(100)); m_Quote.AddGroup(trade); }
private IEnumerable<NoMDEntriesGroup> GetAllNoMDEntries(QuickFix.FIX42.MarketDataSnapshotFullRefresh msg) { int count = message.NoMDEntries.getValue(); QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup repeatingMDItem = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); for (int i = 1; i <= count; i++) { message.GetGroup(i, repeatingMDItem); yield return new NoMDEntriesGroup { Symbol = repeatingMDItem.GetField(55), TickBandNoDecPlaces = int.Parse(repeatingMDItem.GetField(5071) }; } }
public void OnMessage(QuickFix.FIX42.MarketDataSnapshotFullRefresh marketDataSnapshot, SessionID session) { MarketPrice marketPrice = new MarketPrice(); marketPrice.Symbol = marketDataSnapshot.Symbol.getValue(); var nomdentries = marketDataSnapshot.NoMDEntries; // message.GetGroup(1, noMdEntries); var grp = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); for (int i = 1; i <= nomdentries.getValue(); i++) { grp = (QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup)marketDataSnapshot.GetGroup(i, grp); // var grp = marketDataSnapshot.GetGroup(i, new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup()) as QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup; MDEntryType priceType = grp.Get(new MDEntryType()); MDEntryPx mdEntryPx = grp.Get(new MDEntryPx()); if (priceType.getValue() == MDEntryType.BID) { marketPrice.Bid = mdEntryPx.getValue(); } else if (priceType.getValue() == MDEntryType.OFFER) { marketPrice.Offer = mdEntryPx.getValue(); } else if (priceType.getValue() == MDEntryType.TRADE) { marketPrice.TradedPrice = mdEntryPx.getValue(); } else if (priceType.getValue() == MDEntryType.TRADING_SESSION_LOW_PRICE) { marketPrice.LowPx = mdEntryPx.getValue(); } else if (priceType.getValue() == MDEntryType.TRADING_SESSION_HIGH_PRICE) { marketPrice.HighPx = mdEntryPx.getValue(); } } if (OnMarketPrice != null) { OnMarketPrice(marketPrice); } }
//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())); } }
internal void marketDataReturned(QuickFix.FIX42.MarketDataSnapshotFullRefresh m) { String id = m.MDReqID.ToString(); QuickFix.FIX42.NewOrderSingle order = orderHashSet[id]; //get price from market snapshot var bid = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); bool setBid = false; //m.GetGroup(1, bid); var offer = new QuickFix.FIX42.MarketDataSnapshotFullRefresh.NoMDEntriesGroup(); bool setOffer = false; //m.GetGroup(2, offer); for (int grpIndex = 1; grpIndex <= m.GetInt(Tags.NoMDEntries); grpIndex += 1) { if (grpIndex == 1) { m.GetGroup(grpIndex, bid); setBid = true; } else { m.GetGroup(grpIndex, offer); setOffer = true; } } decimal price = 0; //if (order.Side.Obj == Side.BUY) switch (order.Side.Obj) { case QuickFix.Fields.Side.BUY: Console.Write("buy"); if (setBid) { price = bid.GetDecimal(Tags.MDEntryPx); } break; case QuickFix.Fields.Side.SELL: Console.Write("sell"); if (setOffer) { price = offer.GetDecimal(Tags.MDEntryPx); } break; } if (!setBid && !setOffer) { price = orderPriceHashSet[id]; } order.Price = new Price(price); if (OrderEvent != null) { OrderEvent(order); } if (_fixConnectionSystem.InitiatorRunning && _connectionViewModel.IsOrderConnected) { Thread sendToTargetThreading = new Thread(new ParameterizedThreadStart(sendToOrderToTarget)); sendToTargetThreading.IsBackground = true; sendToTargetThreading.Start(order); //QuickFix.Session.SendToTarget(order, _fixConnectionSystem.orderSession.SessionID); } }