コード例 #1
0
        /// <summary>
        /// genera un mensaje especifico para Dukascopy
        /// </summary>
        /// <param name="ticker"></param>
        /// <param name="subscriptionRequestType"></param>
        public static void UpdateFeedSubscription(string ticker, SubscriptionRequestType subscriptionRequestType)
        {
            int topOfBook = 1;

            QuickFix44.MarketDataRequest message =
                new QuickFix44.MarketDataRequest(
                    new MDReqID("1"),
                    subscriptionRequestType,
                    new MarketDepth(topOfBook));

            QuickFix44.MarketDataRequest.NoRelatedSym tickersGroup = new QuickFix44.MarketDataRequest.NoRelatedSym();
            tickersGroup.set(new QuickFix.Symbol(ticker));
            message.addGroup(tickersGroup);

            QuickFix44.MarketDataRequest.NoMDEntryTypes sidesGroup = new QuickFix44.MarketDataRequest.NoMDEntryTypes();
            sidesGroup.set(new QuickFix.MDEntryType(MDEntryType.BID));
            message.addGroup(sidesGroup);
            sidesGroup.set(new QuickFix.MDEntryType(MDEntryType.OFFER));
            message.addGroup(sidesGroup);

            message.set(new MDUpdateType(MDUpdateType.FULL_REFRESH));
            message.set(new NoRelatedSym(1));

            Credential dukascopyCredential = CredentialFactory.GetCredential(Counterpart.Dukascopy);

            Session.sendToTarget(message, dukascopyCredential.FeedSenderCompID, dukascopyCredential.FeedTargetCompID);
        }
コード例 #2
0
ファイル: ExampleApplication.cs プロジェクト: zeropool/Vigoth
        /**
         * Capture and process the trading session status updates, part of the login process
         */
        public override void onMessage(QuickFix44.TradingSessionStatus status, QuickFix.SessionID session)
        {
            // send notification
            Console.WriteLine("TradingSessionStatus received");
            sessionStatus = status;

            // subscribe to CollateralReports
            QuickFix44.CollateralInquiry collateralInq = new QuickFix44.CollateralInquiry();
            collateralInq.set(new QuickFix.CollInquiryID(nextID().ToString()));
            collateralInq.set(subscriptionType);
            send(collateralInq, session);

            // create a MarketDataRequest to subscribe
            QuickFix44.MarketDataRequest dataRequest = new QuickFix44.MarketDataRequest();
            dataRequest.set(new QuickFix.MDReqID(nextID().ToString()));
            dataRequest.set(new QuickFix.MarketDepth(1)); // top of book is only choice for retail
            dataRequest.set(new QuickFix.MDUpdateType(QuickFix.MDUpdateType.FULL_REFRESH));
            dataRequest.set(subscriptionType);
            // add the type of entries desired in the refresh
            // bid
            QuickFix44.MarketDataRequest.NoMDEntryTypes entryTypes;
            entryTypes = new QuickFix44.MarketDataRequest.NoMDEntryTypes();
            entryTypes.set(new QuickFix.MDEntryType(QuickFix.MDEntryType.BID));
            dataRequest.addGroup(entryTypes);
            // ask
            entryTypes = new QuickFix44.MarketDataRequest.NoMDEntryTypes();
            entryTypes.set(new QuickFix.MDEntryType(QuickFix.MDEntryType.OFFER));
            dataRequest.addGroup(entryTypes);
            // go through the sessionStatus in order to name each instrument to subscribe to
            for (uint g = 1; g <= sessionStatus.getField(new QuickFix.IntField(QuickFix.NoRelatedSym.FIELD)).getValue(); g++)
            {
                QuickFix44.SecurityList.NoRelatedSym      relatedSymbols = new QuickFix44.SecurityList.NoRelatedSym();
                QuickFix44.SecurityList.NoRelatedSym      symbolGroup    = (QuickFix44.SecurityList.NoRelatedSym)sessionStatus.getGroup(g, relatedSymbols);
                QuickFix44.MarketDataRequest.NoRelatedSym instrument     = new QuickFix44.MarketDataRequest.NoRelatedSym();

                instrument.set(symbolGroup.getSymbol());
                dataRequest.addGroup(instrument);
            }
            // send notification
            Console.WriteLine("MarketDataRequest sent");
            // send message to the API
            send(dataRequest, sessionID_md);
            // fire an event that the login is complete
            if (this.loginComplete != null)
            {
                this.loginComplete();
            }
        }
コード例 #3
0
        private static bool AddBidAskQueryClause(Message msg, string ticker)
        {
            var simGroup = new QuickFix44.MarketDataRequest.NoRelatedSym(); // 146=1

            // подписаться на символ по его коду?
            if (subscribeBySecurityId)
            {
                int tickerCode;
                if (!TickerCodeDictionary.Instance.tickerCode.TryGetValue(ticker, out tickerCode))
                {
                    Logger.ErrorFormat("Запрос котировки {0} - нет кода", ticker);
                    return(false);
                }

                simGroup.setField(new SecurityID(tickerCode.ToString())); // 48=4006 symbol
                simGroup.setField(new SecurityIDSource("8"));             // 22=8 symbol
            }
            else
            // подписаться по названию
            {
                simGroup.setField(new Symbol(TickerCodeDictionary.Instance.GetTickerNameFormatted(ticker)));
            }

            // два отдельных запроса на bid-ask?
            if (distinctQueriesForBidAsk)
            {
                var group = new QuickFix44.MarketDataRequest.NoMDEntryTypes(); // 267=2
                group.setField(new MDEntryType('0'));                          // 269=0 (bid)
                simGroup.addGroup(group);

                group = new QuickFix44.MarketDataRequest.NoMDEntryTypes();
                group.setField(new MDEntryType('1')); // 269=1 (offer)
                simGroup.addGroup(group);
            }
            else
            // один запрос
            {
                var group = new QuickFix44.MarketDataRequest.NoMDEntryTypes(); // 267=2
                group.setField(new MDEntryType('2'));                          // 269=0 (bid + offer)
                simGroup.addGroup(group);
            }
            msg.addGroup(simGroup);

            msg.setField(new NoRelatedSym(1)); // 1 subscription
            msg.setField(new Symbol(ticker));

            return(true);
        }
コード例 #4
0
ファイル: QuoteRequest.cs プロジェクト: johnmensen/TradeSharp
        private static bool AddBidAskQueryClause(Message msg, string ticker)
        {
            var simGroup = new QuickFix44.MarketDataRequest.NoRelatedSym(); // 146=1

            // подписаться на символ по его коду?
            if (subscribeBySecurityId)
            {
                int tickerCode;
                if (!TickerCodeDictionary.Instance.tickerCode.TryGetValue(ticker, out tickerCode))
                {
                    Logger.ErrorFormat("Запрос котировки {0} - нет кода", ticker);
                    return false;
                }

                simGroup.setField(new SecurityID(tickerCode.ToString())); // 48=4006 symbol
                simGroup.setField(new SecurityIDSource("8")); // 22=8 symbol
            }
            else
            // подписаться по названию
            {
                simGroup.setField(new Symbol(TickerCodeDictionary.Instance.GetTickerNameFormatted(ticker)));
            }

            // два отдельных запроса на bid-ask?
            if (distinctQueriesForBidAsk)
            {
                var group = new QuickFix44.MarketDataRequest.NoMDEntryTypes(); // 267=2
                group.setField(new MDEntryType('0')); // 269=0 (bid)
                simGroup.addGroup(group);

                group = new QuickFix44.MarketDataRequest.NoMDEntryTypes();
                group.setField(new MDEntryType('1')); // 269=1 (offer)
                simGroup.addGroup(group);
            }
            else
            // один запрос
            {
                var group = new QuickFix44.MarketDataRequest.NoMDEntryTypes(); // 267=2
                group.setField(new MDEntryType('2')); // 269=0 (bid + offer)
                simGroup.addGroup(group);
            }
            msg.addGroup(simGroup);

            msg.setField(new NoRelatedSym(1)); // 1 subscription
            msg.setField(new Symbol(ticker));

            return true;
        }