OnixS C++ FIX Engine  3.24.0
API Documentation
FIX Message

Inner Contents

 Manipulating FIX Message Fields
 FIX Repeating Groups

Detailed Description

In general, FIX message represents a sequence of the fields whose values are associated with unique numbers (tags).

A common way of presenting a FIX message is called the tag-value FIX message format. In such a format, all fields are presented as tag=value pairs and are delimited by special <SOH> symbol.

The following image depicts the structure of the FIX message in tag-value format:


Message class

OnixS C++ FIX Engine exposes OnixS::FIX::Message class to encapsulate all services related with handling FIX messages.

Constructing Blank FIX Message

To create a blank FIX Message object, the OnixS::FIX::Message constructor must be used. It initializes a message of the specified type and FIX protocol version with no fields, presented except couple of service fields, like those which identify a type and version of the FIX protocol which this constructed message belongs to.

By reason of the internal design you cannot change the message type of the created message and perform the validation correctly, when a FIX message is created with the certain type then the particular message structure is associated with this message to perform validation and determine undefined fields, so you need to create a new message when you want to change the message type.

Converting Message from and to Raw (Tag-Value) Format

The OnixS::FIX::Message constructor is available to construct a message instance from its raw (tag-value) representation.

Several overloads of the OnixS::FIX::Message::toString method are available to build tag-value presentation of a message instance. These overloads also simplify debugging and monitoring.

Validating FIX Message

In addition to the presence of a particular field in the message of a certain type, the FIX protocol also defines whether the presence of fields are strictly required in the message, whether they are required under certain conditions, or whether they are optional. To check for the presence of all required fields, the OnixS::FIX::Message::validate method must be used. This process is called "message validation" in the C++ FIX Engine terminology.


The following example demonstrates how messages can be created and parsed from the raw representation.

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX42;
// Constructs blank "New Order - Single" message.
Message order(Values::MsgType::Order_Single, ProtocolVersion::FIX_42);
// Updates BodyLength (9) and CheckSum (10) fields with actual values.
std::cout << "Order " << order.toString() << std::endl;
// Reconstructs message from its raw presentation.
std::string rawOrder =
Message order;
Message::parse(rawOrder.c_str(), rawOrder.length(), order);
std::cout << "Default text representation: " << order.toString() << std::endl;
std::cout << "Human-readable presentation: " << order.toString(' ') << std::endl;
std::cout << "Expanded presentation: " << order.toString('\001', MessageStringingFlag::IncludeFieldName | MessageStringingFlag::IncludeFieldTagNumber) << std::endl;