How to parse a string FIXMessage into a FIXMessage object in c#

15,353

QuickFIX is definitely designed for end-to-end. Some of its classes can be used for other purposes, but there is not much documentation for these less-common use-cases.

You can pass FIX strings into the Message constructor.

// Uses default DataDictionary (e.g. message definitions from FIX spec)
Message::Message( const std::string& string, bool validate )

// Uses a DataDictionary that you supply.
// If your msg has custom fields, you need this one.
// (You'll create a DD from a custom msg definition XML file that
// you'll also need to create)
Message::Message( const std::string& string,
                  const DataDictionary& dataDictionary,
                  bool validate )

To convert that Message to a more specific type, you can feed it to a more-specific-type constructor, such as ExecutionReport(Message).

Have you considered QuickFIX/n, the native C# port?

This will work with QuickFIX/n:

IMessageFactory _defaultMsgFactory = new DefaultMessageFactory();

var dd = new QuickFix.DataDictionary.DataDictionary();
dd.Load("../../../spec/fix/FIX44.xml");

var msg = new QuickFix.FIX44.ExecutionReport();
msg.FromString(msg_string, false, dd, dd, _defaultMsgFactory);

If your XML has heavy customizations, you will probably want to regenerate source and rebuild the libraries first.

Share:
15,353

Related videos on Youtube

Ishwar Jindal
Author by

Ishwar Jindal

Interested in developing mobile apps and web services to develop solutions for some interesting real life problems

Updated on July 14, 2022

Comments

  • Ishwar Jindal
    Ishwar Jindal almost 2 years

    I have string FIX message as input and I want to convert it into a FIX Message. I am using QuickFix 1.13.3 (which I downloaded few days back from quickfix website)

    I am quite new to QuickFix. Most of the sample code/help that google returned is for Java and that too no straight forward way is suggested when an application has FIXMessage payload as string.

    Most of the samples which I have seen on web are the cases where people are using QuickFix for end to end i.e. from communication over socket to get message and cracking it.

    In my case I have my own communication layer which just deliver me a string payload represent a full fledge FIX message. All I need is to parse the string and get a list of all tag/values.

    Though I wrote a small utility myself to parse the FIX message using standard string.split().... but someone suggested me to use QuickFix as it support everything.

    But I am quite struggling to start even for a very basic task on QuickFix so any help re parsing a string payload will be much appreciated.

    Below is what I am looking for

    //Convertor or cracker

    public QuickFix44.Message GetMessage(string payload);
    

    //Caller

    string newOrderSinglePayload = "8=FIX.4.49=13635=D..............";
    
    QuickFix44:Message message = GetMessage(newOrderSinglePayload);
    
    if (message is QuickFix44.NewOrderSingle)
    
    { 
       //I am happy
    }
    

    If QuickFix is too much for this simple work then I am open to use anyother tool (free & opensource)

  • Ishwar Jindal
    Ishwar Jindal about 11 years
    in their .NET API, the ExecutionReport constructor or as a matter of fact any constructor representing the specific type (i.e. NOS) etc don't take Message type as input. Its signature is ExecutionReport(string orderId, string,int........) i.e. like it is to create ER when someone has all inputs
  • Grant Birchmeier
    Grant Birchmeier about 11 years
    Ugh. Sorry, I don't know the wrapper API very well. It does vary from C++ in some ways, which is frustrating. Have you tried QuickFIX/n, the native C# port?
  • Grant Birchmeier
    Grant Birchmeier about 11 years
    I added how to do it in QuickFIX/n.