Search code examples
c#quickfixfix-protocolquickfixn

What is the best way to receive the Bid/Offer price for every tick/price movement using QuickFIX/n


I use the following code currently to get the current prices. Then I receive the values on the public void OnMessage(QuickFix.FIX44.MassQuote m, SessionID s)

            QuickFix.FIX44.MarketDataRequest msg = new QuickFix.FIX44.MarketDataRequest();

            // Fill message fields
            msg.SetField(new MDReqID("001"));
            msg.SetField(new SubscriptionRequestType('1'));
            msg.SetField(new MarketDepth(0));
            msg.SetField(new MDUpdateType(MDUpdateType.FULL_REFRESH));

            // Add the MDEntryTypes group
            QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup noMDEntryTypes = new QuickFix.FIX44.MarketDataRequest.NoMDEntryTypesGroup();
            noMDEntryTypes.SetField(new MDEntryType('0'));
            msg.AddGroup(noMDEntryTypes);

            // Add the NoRelatedSym group
            QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup noRelatedSym = new QuickFix.FIX44.MarketDataRequest.NoRelatedSymGroup();
            noRelatedSym.SetField(new Symbol(pair.Insert(3, "/")));
            msg.AddGroup(noRelatedSym);


            Console.WriteLine("Sending Market Request...");
            if(!_priceSession.SendRedundantResendRequests) _priceSession.SendRedundantResendRequests = true;
            SendMessagePrice(msg);

But this method is not ideal for me. I want to be able to see the current prices as soon as they update. In this small example, I would like to Console.WriteLine() the latest Bid/Offer prices to the console as soon as they update(I want to see the prices of only one currency pair at a time).

It would be great if someone can suggest a better way to get the data more quickly and easily.

Thank you in advance.

EDIT: Response from the server

8=FIX.4.4|9=378|35=i|34=2|49=XXXXX|52=20200122-10:09:26.537|56=QXXX|117=1|296=1|302=001|295=5|299=0|106=0|134=2000000|135=1000000|188=1.10914|190=1.10916|299=1|106=10|134=1800000|135=1000000|188=1.10914|190=1.10916|299=2|106=11|134=1500000|135=500000|188=1.10914|190=1.10916|299=3|106=6|134=1000000|135=100000|188=1.10914|190=1.10916|299=4|106=6|134=2000000|135=5400000|188=1.10913|190=1.10917|10=113|

EDIT: After a while, I get this error after receiving this message from the counterparty

Message Received

incoming: 8=FIX.4.4|9=502|35=W|34=7|49=XXXXX|52=20200122-10:09:28.074|56=QXXX|55=EUR/USD|262=001|268=10|269=0|270=1.10914|271=1700000|299=1|106=6|269=0|270=1.10914|271=1000000|299=3|106=11|269=0|270=1.10914|271=1000000|299=0|106=10|269=0|270=1.10913|271=3000000|299=4|106=10|269=0|270=1.10913|271=1500000|299=2|106=9|269=1|270=1.10916|271=1000000|299=0|106=0|269=1|270=1.10916|271=1000000|299=1|106=10|269=1|270=1.10916|271=500000|299=2|106=11|269=1|270=1.10916|271=100000|299=3|106=6|269=1|270=1.10917|271=4500000|299=4|106=13|10=232

event: Message 7 Rejected: Tag appears more than once (Field=106)


Solution

  • Since you are using PrimeXM the market data updates are conveyed a little differently. They are sending MassQuote messages (msgtype i) which you need to reply with a MassQuoteAck message (msgtype b).

    Remember to echo back the 117/QuoteID from the MassQuote on the MassQuoteAck.

    That should cause the price updates to come in constantly. I assume PrimeXM is waiting for each ACK before sending out new updates.