Search code examples
c#quickfixquickfixn

Handling MassQuote response from Quickfix in C#


I'm developing a basic trading platform with a Buy/Sell button and a Bid/Ask display.

I'm sending a MarketDataRequest successfully -> get a MassQuote response -> Sending a MassQuoteAcknowledgement back and getting the updates.

I just can't figure out how to get the prices out of the response using QuickFixn

Example Response below

8=FIX.4.4|9=132|35=i|34=6|49=XXXXXXX|52=20160517-22:38:56.159|56=XXXXXXXXX|117=4|296=1|302=AP2|295=1|299=0|188=1.97471|190=1.97506|10=053|

I see the prices there, but I can't figure out how to extract that in my c# app.

public void HandleMassQuote(QuickFix.FIX44.MassQuote msg)
{
     try
     {
         // Acknowledgement sending code removed
         if (msg.IsSetField(new QuickFix.Fields.BidSpotRate()))
         {
              BuyPrice = msg.GetField(new QuickFix.Fields.BidSpotRate()).ToString();

              Trace.WriteLine("Bid Rate: " + BuyPrice);
         }
         if (msg.IsSetField(new QuickFix.Fields.OfferSpotRate()))
         {
              SellPrice = msg.GetField(new QuickFix.Fields.OfferSpotRate()).ToString();

              Trace.WriteLine("Offer Rate: " + SellPrice);
         }
     }

     catch (Exception e)
     {
         Trace.WriteLine(e.ToString());
     }
}

Has anyone had experience with this that can point me in the right direction? I'm assuming I'm missing something so obvious but it hasn't dawned on my yet


Solution

  • BidSpotRate and SellSpotRate are within a repeating group, but you're trying to extract them like they're at the top level of the message. Are you catching a FieldNotFound exception?

    Here's your message body:

    117=4      QuoteID
    296=1      NoQuoteSets (indicates 1 QuoteSet group will follow)
      302=AP2    QuoteSetID (first tag of first QuoteSet)
      295=1      NoQuoteEntries (indicates 1 QuoteEntry group will follow)
        299=0       QuoteEntryID (first tag of first QuoteEntry)
        188=1.97471 BidSpotRate
        190=1.97506 SellSpotRate
    

    So, check out this page.

    You need to first extract the first (and only) QuoteSets group, then from that the first (and only) QuoteEntries group, and then call getField on that group.