Skip to content

Message

FIX Message

This section provides an overview of the FIX Message structure, its formation and processing:

• Important terms
• General guidelines for building FIX Messages
• Repeating Groups in FIX Messages
• FAQs


Important terms

FIX session: A FIX session is a bi-directional stream of ordered messages between two parties and in the FIX Protocol specified format.

Field tag: A FIX Message is a sequence of the FIX Protocol defined as well as custom fields and their values. To reduce the size of a message, the FIX Protocol enumerates these fields with positive integers called tags.

Enumerated field: Wherever relevant, the FIX Protocol enumerates field values of certain fields and provides their description.

FIX Message syntax: A FIX Message is a sequence of fields in <tag>=<value><delimiter> format.

Delimiter: <SOH> (ASCII 0x01), displayed as |.

FIX Message blocks: Header, Body and Trailer.

FIXimate: Standard repository for FIX definitions.

Custom fields: Tags 5000–9999 reserved.

Custom message types: Defined via Data Dictionary.


Standard Header

Field Tag Field Name Required Description
8 BeginString Y FIX version
9 BodyLength Y Message length
35 MsgType Y Message type
49 SenderCompID Y Sender
56 TargetCompID Y Receiver
34 MsgSeqNum Y Sequence
52 SendingTime Y Time

Standard Trailer

Field Tag Field Name Required Description
10 CheckSum Y Last field
93 SignatureLength C Conditional
89 Signature N Signature

General guidelines for building FIX Messages

  1. Tags 8, 9, 35 must be first
  2. Tag 10 must be last
  3. Header → Body → Trailer
  4. No duplicate tags
  5. Do not set BodyLength or CheckSum manually

Repeating Groups in FIX Messages

A Repeating Group in FIX is used to represent a group of fields that can occur multiple times within a message.

Each repeating group starts with a field that specifies the number of repeating entries (NumInGroup).

This is followed by a set of fields that repeat based on the value of NumInGroup.


Example of Repeating Group

View Code
539=2|
524=XYZ|
525=B|
538=R5|
524=PQR|
525=C|
538=R4|

Explanation

  • 539=2 → Indicates there are 2 repeating groups
  • Each group contains:
  • 524 (PartyID)
  • 525 (PartyIDSource)
  • 538 (PartyRole)

So structure is:

Group 1: - 524=XYZ
- 525=B
- 538=R5

Group 2: - 524=PQR
- 525=C
- 538=R4


Note

  1. Fields inside a repeating group must follow the exact order defined in the FIX Data Dictionary
  2. NumInGroup field must always come before the repeating group entries
  3. Missing or incorrect order can cause parsing failure
  4. Repeating groups can also be nested

Key Points

  • Repeating groups improve message flexibility
  • They allow multiple entries of similar structured data
  • Widely used in market data, orders, and trade messages

FAQs

This section provides frequently asked questions related to FIX Message handling using QXFIX Engine.

Each FAQ explains a specific functionality of the FixMessage class along with examples.


List of FAQs

  1. What functionalities does the FixMessage class provide?
  2. How do I create a FIX Message?
  3. How do I set fields in different parts of a FIX Message?
  4. What are the different SetField methods available?
  5. How do I extract raw FIX message string and bytes?
  6. How do I work with data type fields?
  7. What is the difference between SetField and AddField?
  8. What are the different GetField methods?
  9. How do I create repeating groups in FIX Message?
  10. How do I read repeating groups from FIX Message?
  11. How does QXFIX Engine validate data types?
  12. How do I validate a FIX Message?
  13. How do I iterate through FIX Message fields?
  14. How do I handle repeating groups during iteration?
  15. How do I get BodyLength and CheckSum?
  16. How do I handle Unicode encoding in FIX Message?
  17. How do I suppress a field from FIX Message?

Each of the above questions is explained in detail below with examples and code snippets.

1. What functionalities does the FixMessage class provide?

View Answer

The FixMessage class provides abstraction of a FIX Message and enables easy manipulation of FIX fields.

It provides the following functionalities:

  • Create FIX Messages
  • Add or set fields in Header, Body, and Trailer
  • Retrieve field values in multiple formats
  • Work with repeating groups
  • Validate FIX messages
  • Convert FIX message into string or byte array
  • Handle encoded and binary data
  • Iterate through fields

The FixMessage class simplifies the process of working with FIX Protocol messages by providing high-level APIs.


2. How do I create a FIX Message?

View Answer

A FIX Message can be created using the FixMessage class by specifying the Message Type and FIX Version.

View Code
FixMessage fixMessage = new FixMessage(FixMessageTypes.NewOrder_Single_D, "FIX.4.2");

FixMessage fixMessage = new FixMessage(U9, "FIX.4.4");

In the above examples:

  • FixMessageTypes.NewOrder_Single_D represents a standard FIX message type
  • "FIX.4.2" and "FIX.4.4" represent FIX protocol versions
  • Custom message types can also be used

3. How do I set fields in different parts of a FIX Message?

View Answer

The FixFieldTag class includes all FIX Protocol defined fields.

Fields can be set in different parts of a FIX Message:

  • Header
  • Body
  • Trailer

You can set fields using either predefined FIX field tags or custom tags.

Setting Header fields

View Code
fixMessage.Header.SetField(FixFieldTag.sgSeqNum_34, 1);
fixMessage.Header.SetField(FixFieldTag.SenderCompID_49, "FF");
View Code
fixMessage.Header.SetField(56, "AAACorporation");
fixMessage.Header.SetField(5660, "AAA");

Setting Body fields

View Code
fixMessage.Body.SetField(FixFieldTag.OrderQty_38, 5);

fixMessage.SetField(FixFieldTag.OrderQty_38, 5);

fixMessage.SetField(FixFieldTag.OrderQty_38, "5");

Setting Trailer fields

View Code
fixMessage.Trailer.SetDataField(89, "ABCL");

fixMessage.Trailer.SetDataField(FixFieldTag.Signature_89, "ABCL");

Key Points

  • Header fields must be set using fixMessage.Header
  • Body fields can be set using fixMessage or fixMessage.Body
  • Trailer fields must be set using fixMessage.Trailer
  • Both tag numbers and FixFieldTag constants can be used
  • Custom fields are also supported

4. What are the different SetField methods available?

View Answer

The FixMessage class provides multiple ways to set fields.

You can set fields using:

  • FixField objects
  • Specific typed fields (like FixFloatField)
  • Tag-value pairs
View Code
FixFloatField settlCurrFxRate = new FixFloatField(FixFieldTag.SettlCurrFxRate_155, 323.33);
fixMessage.SetField(settlCurrFxRate);
View Code
FixField fixField = new FixField(123, "N");
fixMessage.SetField(fixField);
View Code
fixMessage.SetField(49, "IBN456");
fixMessage.SetField(123, "Y");
fixMessage.SetField(44, "56.25");

Key Points

  • You can use strongly typed field classes
  • You can use generic FixField
  • You can directly use tag-value pairs
  • All methods internally map to FIX message structure

5. How do I extract raw FIX message string and bytes?

View Answer

The FixMessage class provides methods to convert the FIX Message into:

  • String format
  • Byte array format
View Code
string fixMessageString = fixMessage.ToString(1, true);

byte[] fixMessageBytes = fixMessage.ToArray(1, true);

Explanation

  • ToString() converts FIX message into readable string format
  • ToArray() converts FIX message into byte stream
  • Parameters control formatting and delimiter usage

6. How do I work with data type fields?

View Answer

Data type fields in FIX Messages are used when field values contain binary or encoded data.

These fields must be handled carefully using special methods.

View Code
fixMessage.SetDataField(FixFieldTag.EncodedText_355, "Hello World");
View Code
byte[] bEncodedText = GetUnicodeText();
fixMessage.SetField(FixFieldTag.EncodedText_355, bEncodedText);
View Code
FixMessage fixMessage = new FixMessage(FixMessageTypes.NewOrder_Single_D, "FIX.4.2");

string rawDataContent = "Hello|World";

fixMessage.SetDataField(FixFieldTag.RawData_96, rawDataContent);

Key Points

  • Use SetDataField for encoded or binary fields
  • Supports string and byte[] inputs
  • Required for handling FIX data fields like RawData and EncodedText

7. What is the difference between SetField and AddField?

View Answer

The difference between SetField and AddField is related to how fields are handled internally.

SetField

  • Replaces the value if the field already exists
  • Ensures only one instance of the field is present

AddField

  • Adds a new instance of the field
  • Allows duplicate fields (used in repeating groups or special cases)

Key Points

  • Use SetField for normal FIX fields
  • Use AddField when multiple instances of the same field are required
  • AddField is generally used in repeating group scenarios

8. What are the different GetField methods?

View Answer

The FixMessage class provides multiple methods to retrieve field values.

You can retrieve values as:

  • String
  • Integer
  • Byte array
  • Specific data types
View Code
string possDupFlag = fixMessage.Header.GetField(43);
View Code
string senderCompID = fixMessage.Header.GetField(49);
View Code
byte[] bSecureData = fixMessage.Header.GetField(FixFieldTag.SecureData_91);
View Code
string symbol = fixMessage.GetField(FixFieldTag.Symbol_55);
View Code
int quantity = fixMessage.GetFieldAsInt(FixFieldTag.Quantity_53);
View Code
string checkSum = fixMessage.Trailer.GetField(FixFieldTag.CheckSum_10);

Key Points

  • Use GetField for string values
  • Use GetFieldAsInt for numeric values
  • Header, Body, and Trailer fields can be accessed separately
  • Supports both tag numbers and FixFieldTag constants

9. How do I create repeating groups in FIX Message?

View Answer

Repeating groups allow multiple sets of structured fields within a FIX Message.

They are created using FixRepeatingGroupField and FixGroupField.

View Code
FixRepeatingGroupField fixRepeatingGroupField = new FixRepeatingGroupField(268, 2);

FixGroupField fixGroupField = new FixGroupField();
fixGroupField.SetField(79, 0);

fixRepeatingGroupField.AddGroup(fixGroupField);

Explanation

  • 268 → NumInGroup field
  • 2 → Number of groups
  • FixGroupField represents one group entry

Key Points

  • Always specify NumInGroup first
  • Add each group using AddGroup()
  • Maintain correct field order inside group

10. How do I read repeating groups from FIX Message?

View Answer

You can read repeating groups using the FixRepeatingGroupField class.

First check if the repeating group exists, then retrieve it.

View Code
bool hasRGF268 = fixMessage.HasRepeatingGroup(FixFieldTag.NoMDEntries_268);

FixRepeatingGroupField fixRepeatingGroupField =
    fixMessage.GetRepeatingGroupField(FixFieldTag.NoMDEntries_268);

Explanation

  • HasRepeatingGroup() checks existence
  • GetRepeatingGroupField() retrieves the group

Key Points

  • Always check existence before retrieving
  • Use correct FIX tag for group
  • Retrieved object contains all group entries

11. How does QXFIX Engine validate data types?

View Answer

QXFIX Engine validates data types automatically based on FIX Protocol definitions.

If invalid data is provided, validation errors may occur.

View Code
fixMessage.Header.SetField(43, 1000.2);
fixMessage.Header.SetField(43, "1000.2");

Explanation

  • FIX fields have defined data types
  • Engine validates values against expected types
  • Incorrect types may lead to parsing or runtime errors

Key Points

  • Always use correct data types
  • Prefer typed field classes when possible
  • Validation ensures message correctness

12. How do I validate a FIX Message?

View Answer

FIX Message validation ensures that the message structure and field values comply with FIX Protocol standards.

QXFIX Engine provides validation using FIX dialect and data dictionary.

View Code
FixDialect fixDialect = new FixDialect(eFixVersion.FIX44);
View Code
FixDataDictionary fixDataDictionary = fixDialect.GetFixDataDictionary();

Explanation

  • FixDialect defines FIX version rules
  • FixDataDictionary contains field and message definitions
  • Validation is performed based on these definitions

Key Points

  • Always use correct FIX version
  • Data dictionary is required for validation
  • Helps ensure message correctness and compliance

13. How do I iterate through FIX Message fields?

View Answer

You can iterate through FIX Message fields using collections provided in the FixMessage class.

View Code
foreach (FixField fixField in fixMessage.Header.FixFieldCollection)
{
    Console.WriteLine(fixField.Tag);
}

Explanation

  • FixFieldCollection contains all fields in that section
  • You can iterate using foreach loop
  • Access tag and value for each field

Key Points

  • Works for Header, Body, and Trailer
  • Useful for debugging and logging
  • Can be extended to process fields dynamically

14. How do I handle repeating groups during iteration?

View Answer

While iterating through FIX Message fields, you may encounter repeating groups.

These can be identified and processed separately.

View Code
if (fixField is FixRepeatingGroupField)
{
    FixRepeatingGroupField rg = fixField as FixRepeatingGroupField;
}

Explanation

  • Check if field is FixRepeatingGroupField
  • Cast it to access group entries
  • Iterate through each group if needed

Key Points

  • Repeating groups require special handling
  • Always check type before casting
  • Each group contains multiple field sets

15. How do I get BodyLength and CheckSum?

View Answer

FIX Messages automatically calculate BodyLength and CheckSum.

You can retrieve them using provided methods.

View Code
int BodyLength = fixMessage.GetBodyLength();
int CheckSum = fixMessage.GetCheckSum();

Explanation

  • BodyLength represents message size
  • CheckSum ensures message integrity

Key Points

  • Do not manually set these values
  • Always use provided methods
  • Automatically calculated by engine

16. How do I handle Unicode encoding in FIX Message?

View Answer

QXFIX Engine supports Unicode encoding for FIX Messages.

This is useful when dealing with international text data.

View Code
fixMessage.SetEncodedDataField(eMessageEncoding.Unicode, FixField.EncodedText_355, uCodeText);

Explanation

  • Unicode encoding allows multi-language support
  • EncodedText field is used for encoded data

Key Points

  • Use encoding methods for special characters
  • Required for global trading systems
  • Ensures proper data transmission

17. How do I suppress a field from FIX Message?

View Answer

You can suppress (exclude) a field from the FIX Message using built-in methods.

View Code
fixMessage.ExcludeField(FixFieldTag.Symbol_55);

Explanation

  • ExcludeField removes a field from the message
  • Useful for dynamic message customization

Key Points

  • Field will not be included in output
  • Helps control message content
  • Useful in conditional scenarios