public void SubscribeMarketData(string symbol, string reqID)
        {
            MDReqID mdReqID = new MDReqID(reqID);
            SubscriptionRequestType subType      = new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES);
            MarketDepth             marketDepth  = new MarketDepth(1);
            MDUpdateType            mdUpdateType = new MDUpdateType(0);

            QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup marketDataEntryGroup = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup();
            marketDataEntryGroup.SetField(new MDEntryType(MDEntryType.BID));
            marketDataEntryGroup.SetField(new MDEntryType(MDEntryType.OFFER));

            QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symbolGroup = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup();
            symbolGroup.Set(new Symbol(symbol));

            QuickFix.FIX44.MarketDataRequest message = new QuickFix.FIX44.MarketDataRequest();
            message.SetField(mdReqID);
            message.SetField(subType);
            message.SetField(marketDepth);
            message.SetField(mdUpdateType);

            message.AddGroup(marketDataEntryGroup);
            message.AddGroup(symbolGroup);

            if (m_SessionID != null)
            {
                Session.SendToTarget(message, m_SessionID);
            }
        }
Ejemplo n.º 2
0
        private void QueryMarketDataRequest()
        {
            QuickFix.FIX44.MarketDataRequest result = new QuickFix.FIX44.MarketDataRequest();
            result.SetField(new MDReqID(DateTime.Now.Millisecond.ToString()));

            var noContraBrokersGroup = new QuickFix.FIX44.ExecutionReport.NoContraBrokersGroup();

            noContraBrokersGroup.Set(QueryPool());
            result.AddGroup(noContraBrokersGroup);

            QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup symGroup = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup();
            symGroup.SetField(QuerySymbol());
            symGroup.SetField(new MDUpdateType(MDUpdateType.INCREMENTAL_REFRESH));
            symGroup.SetField(new MarketDepth(0));
            symGroup.SetField(new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES));

            QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup typesGroup = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup();
            typesGroup.SetField(new MDEntryType(MDEntryType.BID));
            result.AddGroup(typesGroup);

            typesGroup = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup();
            typesGroup.SetField(new MDEntryType(MDEntryType.OFFER));
            result.AddGroup(symGroup);

            Console.WriteLine(result);

            SendMessage(result, ".MD");
        }
        /// <summary>
        /// Creates a FIX4.4 MarketDataRequest message.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="security"></param>
        /// <param name="subscriptionType"></param>
        /// <param name="depth"></param>
        /// <returns></returns>
        public QuickFix.FIX44.MarketDataRequest MarketDataRequest(string id, Security security, char subscriptionType, int depth)
        {
            QuickFix.FIX44.MarketDataRequest marketDataRequest = new QuickFix.FIX44.MarketDataRequest();

            QuickFix.Fields.NoRelatedSym noRelatedSym = new QuickFix.Fields.NoRelatedSym(1);
            marketDataRequest.SetField(noRelatedSym);

            QuickFix.Fields.MDReqID mdReqId = new QuickFix.Fields.MDReqID(id);
            marketDataRequest.SetField(mdReqId);

            QuickFix.Fields.SubscriptionRequestType subscriptionRequestType = new QuickFix.Fields.SubscriptionRequestType(subscriptionType);
            marketDataRequest.SetField(subscriptionRequestType);

            QuickFix.Fields.MarketDepth marketDepth = new QuickFix.Fields.MarketDepth(depth);
            marketDataRequest.SetField(marketDepth);

            QuickFix.Fields.MDUpdateType mdUpdateType = new QuickFix.Fields.MDUpdateType(MarketDataUpdateType.FullRefresh);
            marketDataRequest.SetField(mdUpdateType);

            QuickFix.Fields.NoMDEntryTypes noMdEntryType = new QuickFix.Fields.NoMDEntryTypes(2);
            marketDataRequest.SetField(noMdEntryType);

            QuickFix.Fields.Symbol symbol = new QuickFix.Fields.Symbol(security.Symbol);
            QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup relatedSymbols = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup();
            relatedSymbols.SetField(symbol);
            marketDataRequest.AddGroup(relatedSymbols);

            QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup mdEntryTypes = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup();
            {
                mdEntryTypes.SetField(new QuickFix.Fields.MDEntryType(MarketDataEntryType.Bid));
                marketDataRequest.AddGroup(mdEntryTypes);
                mdEntryTypes.SetField(new QuickFix.Fields.MDEntryType(MarketDataEntryType.Offer));
                marketDataRequest.AddGroup(mdEntryTypes);
            }

            return(marketDataRequest);
        }