Ejemplo n.º 1
0
        public void OnMessage(FixSpec.MarketDataRequest message, SessionID sessionId)
        {
            ResolveMarketDataRequest(message, out Symbol symbol, out char bidAskObj, out string currencyCodeObj);

            //prepare MassQuote response

            CalculateNewPrice(currencyCodeObj, out decimal bidPrice, out decimal askPrice);

            FixSpec.MassQuote massQuote = new FixSpec.MassQuote(new QuoteID(Guid.NewGuid().ToString("N")));

            FixSpec.MassQuote.NoQuoteSetsGroup quoteSetsGroup = new FixSpec.MassQuote.NoQuoteSetsGroup();

            NoQuoteEntries noQuoteEntries = new NoQuoteEntries(1);

            quoteSetsGroup.Set(noQuoteEntries);

            QuoteSetID quoteSetId = new QuoteSetID(symbol.Obj);

            quoteSetsGroup.Set(quoteSetId);

            FixSpec.MassQuote.NoQuoteSetsGroup.NoQuoteEntriesGroup quoteEntriesGroup =
                new FixSpec.MassQuote.NoQuoteSetsGroup.NoQuoteEntriesGroup();

            quoteEntriesGroup.QuoteEntryID = new QuoteEntryID(currencyCodeObj);

            if (bidAskObj == MDEntryType.BID)
            {
                quoteEntriesGroup.SetField(new BidSpotRate(bidPrice));
            }

            if (bidAskObj == MDEntryType.OFFER)
            {
                quoteEntriesGroup.SetField(new OfferSpotRate(askPrice));
            }

            quoteSetsGroup.AddGroup(quoteEntriesGroup);

            massQuote.AddGroup(quoteSetsGroup);


            Session.LookupSession(sessionId).Send(massQuote);

            Console.WriteLine($"{currencyCodeObj} : bid -> {bidPrice} | ask -> {askPrice} ");
        }
Ejemplo n.º 2
0
        private FixSpec.MarketDataRequest QueryMarketDataRequest()
        {
            MDReqID mdReqId = new MDReqID("CLIAPP");
            SubscriptionRequestType subType     = new SubscriptionRequestType(SubscriptionRequestType.SNAPSHOT);
            MarketDepth             marketDepth = new MarketDepth(0);

            FixSpec.MarketDataRequest.NoMDEntryTypesGroup marketDataEntryGroup = new FixSpec.MarketDataRequest.NoMDEntryTypesGroup();
            marketDataEntryGroup.Set(new MDEntryType(MDEntryType.BID));

            var symbolGroup = new FixSpec.MarketDataRequest.NoRelatedSymGroup();

            symbolGroup.Set(new Symbol("EURUSD"));

            var message = new FixSpec.MarketDataRequest(mdReqId, subType, marketDepth);

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

            return(message);
        }