예제 #1
0
        /// <summary>
        /// Request Bid and offer prices subscription for a specific contract.
        /// </summary>
        /// <param name="SecEx">Exchange</param>
        /// <param name="symbol">Exchange symbol for contract</param>
        /// <param name="secID">unique identifier supplied by the exchnage for this contract
        /// For eurex this is the ticker and expiration</param>
        public void ttMarketDataRequest(string[] instrument, char reqType)
        {
            //string[] instrument must contain:
            //{SecurityExchange, Symbol,SecurityType,MaturityMonthYear} or
            //{SecurityExchange, Symbol,SecurityID}

            try
            {
                QuickFix42.MarketDataRequest mdr = new QuickFix42.MarketDataRequest();

                mdr.set(new QuickFix.MDReqID(uniqueID()));

                mdr.set(new QuickFix.SubscriptionRequestType(reqType));
                mdr.set(new QuickFix.MDUpdateType(QuickFix.MDUpdateType.FULL_REFRESH)); //required if above type is SNAPSHOT_PLUS_UPDATES
                //1=Top of Book, 0 = full book, other integer equals number of levels
                mdr.set(new QuickFix.MarketDepth(1));
                mdr.set(new QuickFix.AggregatedBook(true));

                QuickFix42.MarketDataRequest.NoMDEntryTypes tgroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
                tgroup.set(new QuickFix.MDEntryType(QuickFix.MDEntryType.BID));
                mdr.addGroup(tgroup);
                tgroup.set(new QuickFix.MDEntryType(QuickFix.MDEntryType.OFFER));
                mdr.addGroup(tgroup);
                tgroup.set(new QuickFix.MDEntryType(QuickFix.MDEntryType.TRADE));
                mdr.addGroup(tgroup);

                QuickFix42.MarketDataRequest.NoRelatedSym sgroup = new QuickFix42.MarketDataRequest.NoRelatedSym();

                // Define instrument
                sgroup.set(new QuickFix.SecurityExchange(instrument[0]));
                sgroup.set(new QuickFix.Symbol(instrument[1]));

                if (instrument.GetLength(0) == 4)
                {
                    sgroup.set(new QuickFix.SecurityType(instrument[2]));
                    sgroup.set(new QuickFix.MaturityMonthYear(instrument[3]));
                }
                else if (instrument.GetLength(0) == 3)
                {
                    sgroup.set(new QuickFix.SecurityID(instrument[2]));
                }
                else
                {
                    throw new System.Exception("Incorrect parameters for insturment definition");
                }

                mdr.addGroup(sgroup);

                QuickFix.Session.sendToTarget(mdr, priceSessionID);
            }
            catch (Exception ex)
            { Console.WriteLine(ex.ToString()); }
        }
예제 #2
0
        public void MarketDataRequest(QuickFix42.SecurityDefinition securityDefinition)
        {
            QuickFix42.MarketDataRequest marketDataRequest =
                new QuickFix42.MarketDataRequest(new MDReqID(DateTime.Now.ToString()),
                new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT_PLUS_UPDATES),
                new MarketDepth(1));
            marketDataRequest.setField(new MDUpdateType(MDUpdateType.FULL_REFRESH));
            marketDataRequest.setField(new AggregatedBook(true));

            QuickFix42.MarketDataRequest.NoMDEntryTypes marketDataEntyGroupBid = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            marketDataEntyGroupBid.set(new MDEntryType(MDEntryType.BID));
            marketDataRequest.addGroup(marketDataEntyGroupBid);

            QuickFix42.MarketDataRequest.NoMDEntryTypes marketDataEntyGroupOffer = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            marketDataEntyGroupOffer.set(new MDEntryType(MDEntryType.OFFER));
            marketDataRequest.addGroup(marketDataEntyGroupOffer);

            /** Create Component Block NoRelatedSym */
            QuickFix42.MarketDataRequest.NoRelatedSym noRelatedSym = new QuickFix42.MarketDataRequest.NoRelatedSym();

            SecurityExchange securityExchange = new SecurityExchange();
            securityDefinition.getField(securityExchange);
            noRelatedSym.setField(securityExchange);

            SecurityType securityType = new SecurityType();
            securityDefinition.getField(securityType);
            noRelatedSym.setField(securityType);

            Symbol symbol = new Symbol();
            securityDefinition.getField(symbol);
            noRelatedSym.setField(symbol);

            //MaturityMonthYear maturityMonthYear = new MaturityMonthYear();
            //securityDefinition.getField(maturityMonthYear);
            //noRelatedSym.setField(maturityMonthYear);

            SecurityID securityId = new SecurityID();
            securityDefinition.getField(securityId);
            noRelatedSym.setField(securityId);

            marketDataRequest.addGroup(noRelatedSym);

            Session.sendToTarget(marketDataRequest, GetPriceSession());
        }
        public override void Send(FIXMarketDataRequest Request)
        {
            //Console.WriteLine("REQUEST");

            QuickFix42.MarketDataRequest request = new QuickFix42.MarketDataRequest(
                new QuickFix.MDReqID(Request.MDReqID),
                new QuickFix.SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT), //GS FIX
                new QuickFix.MarketDepth(5));                                           //GS FIX

            //request.set(new QuickFix.MDUpdateType(Request.MDUpdateType));
            //request.set(new QuickFix.AggregatedBook(Request.AggregatedBook));

            QuickFix42.MarketDataRequest.NoMDEntryTypes typeGroup;

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Bid));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Offer));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Trade));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Open));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Close));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.High));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Low));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            QuickFix42.MarketDataRequest.NoRelatedSym symGroup = new QuickFix42.MarketDataRequest.NoRelatedSym();

            FIXRelatedSymGroup Group = Request.GetRelatedSymGroup(0);

            symGroup.set(new QuickFix.Symbol(Group.Symbol.Substring(0, 6)));

            if (Group.Symbol.StartsWith("60") || Group.Symbol.StartsWith("51"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHG"));// 上海
                symGroup.set(new QuickFix.SecurityExchange("SS"));// 上海
            }
            else if (Group.Symbol.StartsWith("00") || Group.Symbol.StartsWith("30") || Group.Symbol.StartsWith("15"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHE"));// 深圳
                symGroup.set(new QuickFix.SecurityExchange("SZ"));// 深圳
            }

            //if (Group.ContainsField(EFIXField.SecurityType)) symGroup.set(new QuickFix.SecurityType(Group.SecurityType));
            //if (Group.ContainsField(EFIXField.MaturityMonthYear)) symGroup.set(new QuickFix.MaturityMonthYear(Group.MaturityMonthYear));
            //if (Group.ContainsField(EFIXField.MaturityDay           )) symGroup.set(new QuickFix.MaturityDay           (Group.MaturityDay           ));
            //if (Group.ContainsField(EFIXField.PutOrCall             )) symGroup.set(new QuickFix.PutOrCall             (Group.PutOrCall             ));
            //if (Group.ContainsField(EFIXField.StrikePrice)) symGroup.set(new QuickFix.StrikePrice(Group.StrikePrice));
            //if (Group.ContainsField(EFIXField.OptAttribute)) symGroup.set(new QuickFix.OptAttribute(Group.OptAttribute));
            //if (Group.ContainsField(EFIXField.SecurityID)) symGroup.set(new QuickFix.SecurityID(Group.SecurityID));
            //if (Group.ContainsField(EFIXField.SecurityExchange)) symGroup.set(new QuickFix.SecurityExchange(Group.SecurityExchange));

            request.addGroup(symGroup);

            symGroup.Dispose();

            if (base.priceSessionID == null)
            {
                Session.sendToTarget(request, orderSessionID);
            }
            else
            {
                Session.sendToTarget(request, priceSessionID);
            }
        }
예제 #4
0
        public override void Send(FIXMarketDataRequest Request)
        {
            //Console.WriteLine("REQUEST");

            QuickFix42.MarketDataRequest request = new QuickFix42.MarketDataRequest(
                new QuickFix.MDReqID(Request.MDReqID),
                new QuickFix.SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT), //GS FIX
                new QuickFix.MarketDepth(5)); //GS FIX

            //request.set(new QuickFix.MDUpdateType(Request.MDUpdateType));
            //request.set(new QuickFix.AggregatedBook(Request.AggregatedBook));

            QuickFix42.MarketDataRequest.NoMDEntryTypes typeGroup;

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Bid));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Offer));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            typeGroup.set(new MDEntryType(FIXMDEntryType.Trade));
            request.addGroup(typeGroup);
            typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Open));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Close));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.High));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            //typeGroup = new QuickFix42.MarketDataRequest.NoMDEntryTypes();
            //typeGroup.set(new MDEntryType(FIXMDEntryType.Low));
            //request.addGroup(typeGroup);
            //typeGroup.Dispose();

            QuickFix42.MarketDataRequest.NoRelatedSym symGroup = new QuickFix42.MarketDataRequest.NoRelatedSym();

            FIXRelatedSymGroup Group = Request.GetRelatedSymGroup(0);

            symGroup.set(new QuickFix.Symbol(Group.Symbol.Substring(0, 6)));

            if (Group.Symbol.StartsWith("60") || Group.Symbol.StartsWith("51"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHG"));// 上海
                symGroup.set(new QuickFix.SecurityExchange("SS"));// 上海
            }
            else if (Group.Symbol.StartsWith("00") || Group.Symbol.StartsWith("30") || Group.Symbol.StartsWith("15"))
            {
                //order.set(new QuickFix.SecurityExchange("XSHE"));// 深圳
                symGroup.set(new QuickFix.SecurityExchange("SZ"));// 深圳
            }

            //if (Group.ContainsField(EFIXField.SecurityType)) symGroup.set(new QuickFix.SecurityType(Group.SecurityType));
            //if (Group.ContainsField(EFIXField.MaturityMonthYear)) symGroup.set(new QuickFix.MaturityMonthYear(Group.MaturityMonthYear));
            //if (Group.ContainsField(EFIXField.MaturityDay           )) symGroup.set(new QuickFix.MaturityDay           (Group.MaturityDay           ));
            //if (Group.ContainsField(EFIXField.PutOrCall             )) symGroup.set(new QuickFix.PutOrCall             (Group.PutOrCall             ));
            //if (Group.ContainsField(EFIXField.StrikePrice)) symGroup.set(new QuickFix.StrikePrice(Group.StrikePrice));
            //if (Group.ContainsField(EFIXField.OptAttribute)) symGroup.set(new QuickFix.OptAttribute(Group.OptAttribute));
            //if (Group.ContainsField(EFIXField.SecurityID)) symGroup.set(new QuickFix.SecurityID(Group.SecurityID));
            //if (Group.ContainsField(EFIXField.SecurityExchange)) symGroup.set(new QuickFix.SecurityExchange(Group.SecurityExchange));

            request.addGroup(symGroup);

            symGroup.Dispose();

            if(base.priceSessionID == null)
                Session.sendToTarget(request, orderSessionID);
            else
                Session.sendToTarget(request, priceSessionID);
        }