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); }
public void OnMessage(QuickFix.FIX42.MarketDataSnapshotFullRefresh m, SessionID s) { Console.WriteLine("Data Request"); if (dataRequestMessageReturned != null) { dataRequestMessageReturned(m); } }
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); } }
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); }
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); } }