예제 #1
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());
        }
예제 #2
0
        public override void onMessage(QuickFix42.SecurityDefinition securityDefinition, SessionID sessionID)
        {
            //Console.WriteLine("securityDefinition " + securityDefinition);

            try
            {
                SecurityType securityType = new SecurityType();
                securityDefinition.getField(securityType);

                SecurityID securityID = new SecurityID();
                securityDefinition.getField(securityID);

                //Create the object in the spreadmatrix;

                if(securityType.getValue() == SecurityType.MULTILEGINSTRUMENT)
                {
                    string longUnderlyingMaturityMonthYear=null;
                    string shortUnderlyingMaturityMonthYear=null;

                    NoRelatedSym noRelatedSym = securityDefinition.getNoRelatedSym();
                    uint SubContractCount = (uint)noRelatedSym.getValue();

                    if (SubContractCount != 2)
                    {
                        //Console.WriteLine("I don't know how to handle an MLEG with " + SubContractCount + " legs.");
                        return;
                    }

                    SecurityDefinition.NoRelatedSym group = new SecurityDefinition.NoRelatedSym();
                    for (uint i = 0; i < SubContractCount; i++)
                    {
                        securityDefinition.getGroup(i + 1, group);

                        UnderlyingMaturityMonthYear underlyingMaturityMonthYear = new UnderlyingMaturityMonthYear();
                        group.getField(underlyingMaturityMonthYear);

                        Side side = new Side();
                        group.getField(side);

                        if (side.getValue() == QuickFix.Side.SELL)
                        {
                            shortUnderlyingMaturityMonthYear = underlyingMaturityMonthYear.getValue();
                        }
                        else if (side.getValue() == QuickFix.Side.BUY)
                        {
                            longUnderlyingMaturityMonthYear = underlyingMaturityMonthYear.getValue();
                        }
                        else
                        {
                            Console.WriteLine("Unsupport MLEG side: " + side.getValue());
                            return;
                        }
                    }

                    spreadMatrix.CreateSpread(securityID.getValue(), longUnderlyingMaturityMonthYear, shortUnderlyingMaturityMonthYear);
                }
                else if (securityType.getValue() == SecurityType.FUTURE)
                {
                    MaturityMonthYear maturityMonthYear = new MaturityMonthYear();
                    securityDefinition.getField(maturityMonthYear);

                    spreadMatrix.CreateOutright(securityID.ToString(), maturityMonthYear.ToString());
                }
                else
                {
                    Console.WriteLine("Unsupport security type: " + securityType.getField());
                    return;
                }

                MarketDataRequest(securityDefinition, sessionID);
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
            }
        }
예제 #3
0
        public override void onMessage(QuickFix42.SecurityDefinition securityDefinition, SessionID sessionID)
        {
            AddText("securityDefinition " + securityDefinition + Environment.NewLine);

            try
            {
                SecurityExchange securityExchange = new SecurityExchange();
                securityDefinition.getField(securityExchange);

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

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

                SpreadMatrixData smd = SpreadMatrixCollection.Get(securityExchange.getValue(), symbol.getValue());

                if (smd != null)
                {
                    SecurityEntry entry = new SecurityEntry(securityDefinition);
                    smd.Add(entry);
                    MarketDataRequest(securityDefinition);
                }
            }
            catch (Exception exception)
            {
                AddText(exception.Message + Environment.NewLine);
                throw;
            }
        }