Search code examples
c#quickfixfix-protocol

Remove a FIX tag in QuickFIX/n which should be a member of a repeating group but is not?


I'm developing an adapter to read CME execution reports (35=8) and the CME occasionally sends [constant] tag-337 (ContraTrader) and tag-375 (ContraBroker) values, which are members of repeating group tag-382 (NoContraBrokers) according to the FIX 4.2 spec.

Here is the (unmodified FIX 4.2) group definition for 382 that I'm using.

  <group name="NoContraBrokers" required="N">
    <field name="ContraBroker" required="N"/>
    <field name="ContraTrader" required="N"/>
    <field name="ContraTradeQty" required="N"/>
    <field name="ContraTradeTime" required="N"/>
  </group>

The problem is that the CME doesn't send a tag-382 value so QF/n has no way of knowing how many groups to expect and throws an exception when it tries to crack the message.

I've been searching google and reading documentation and I'm perplexed. It would be easy to do something like the following but I think it would mess up messaging checksums and such which would result in a malformed FIX message:

public const string SOH = "\u0001";
//my bad code goes here

public void FromApp(Message message, SessionID sessionID)
{
    if (message.ToString().Contains(SOH + "375="))
    {
        int insertionPoint = message.ToString().IndexOf(SOH + "375=");
        string foo = message.ToString().Insert(insertionPoint, SOH + "382=1");
        Message bar = new Message(foo);
        message = bar;
    }
    try
    {
        Crack(message, sessionID);
    }
    catch (QuickFIXException e)
    {
        //Panic on the dance floor!
    }
}

Example message which throws the exception upon Crack(...){}

8=FIX.4.2 | 9=497 | 35=8 | 34=3 | 43=Y | 49=SOMEVALUE | 52=20150326-20:30:24.943 | 56=ANOTHERVALUE | 122=20150326-14:50:47.226 | 1=SOMEACCOUNT | 6=0 | 11=OrderID12345 | 14=2 | 17=70477:M:691285TN0017346 | 20=0 | 31=525 | 32=2 | 37=70297295250 | 38=5 | 39=1 | 40=2 | 41=0 | 44=510.25 | 48=250618 | 54=2 | 55=ZW | 59=0 | 60=20150326-14:50:47.213 | 75=20150326 | 107=ZWK5 | 150=1 | 151=3 | 167=FUT | 337=TRADE | 375=CME000A | 432=20150326 | 442=1 | 527=702972952502015032617346 | 1028=Y | 1057=Y | 9717=OrderID438346156 | 10=158 |

An alternative would be to redefine the execution report structure in the XML file to remove the group definition and insert 337 and 375 as non-required fields but that makes the adapter very specifically for the CME.

Is there a less daft way to accomplish this?


Solution

  • Does CME have documentation for this particular FIX interface?

    It is incredibly common (nearly always, actually) for counterparties to add or remove custom fields to FIX messages. It's possible that the fields giving you trouble are part of those modifications.

    The documentation should show exactly what changes you need to make in your FIX42.xml file so that your engine's expectations match what CME is sending.