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); } }
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); } }