Log in

FIX TagValue Encoding

FIX TagValue encoding was the original encoding within FIX, and is still the most commonly used encoding today. It's a way of converting messages into a series of bytes to be sent over TCP or another transport.

In the TagValue encoding, fields are encoded as a "tag", followed by =, followed by the value of that field. The tag is an integer which represents a unique field ID. For example, the tag 35 represents the MsgType field, the type of the message. The tag-to-field mapping is typically encoded in a FIX dictionary used by both parties.

Fields are delimited by the Start of Heading control character ("SOH"). Since SOH is non-printable, it may sometimes be displayed as a white square . It's commonly replaced with a pipe character | for human-readability.

35
Tag. Identifies this field as ID 35, which is the MsgType field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
A
Field value for tag 35. 'A' represents a Logon message
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
Hover for explanation

Tags, values and delimiters are all encoded with the single-byte encoding ISO-8859-1. That is, a decimal tag 35 is encoded as the character '3' followed by the character '5', and not the decimal 35.

Both tag and value must contain at least 1 character.

Repeating groups

Certain messages may need to represent an array of records, e.g. a list of securities or a list of trades. The TagValue encoding achieves this by preceding the group elements with a field which specifies the number of elements to follow, called a NumInGroup field. Each element then begins with the same mandatory data field, which also acts as the delimiter between elements, to allow a FIX engine to delineate between elements.

There is no terminator for the final group element. Instead, FIX engines can infer when the final group element has ended by awaiting the first field which does not appear in the group element's definition in the FIX dictionary.

146
Tag. Identifies this field as ID 146, which is the NoRelatedSym field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
2
Field value for tag 146. Indicates there are 2 elements. In this case 2 securities
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
55
Tag. Identifies this field as ID 55, which is the Symbol field. This both begins the first group element, as well as specifies the symbol
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
APPL
Field value for tag 55. Indicates that the first security is Apple stock (APPL)
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
44
Tag. Identifies this field as ID 44, which is the Price field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
168
Field value for tag 44. Indicates that the price of the first group element (Apple) is 168
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
55
Tag. Identifies this field as ID 55, which is the Symbol field. This both begins the second group element, as well as specifies the symbol
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
AMZN
Field value for tag 55. Indicates that the second security is Amazon stock (AMZN)
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
44
Tag. Identifies this field as ID 44, which is the Price field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
185
Field value for tag 44. Indicates that the price of the first group element (Apple) is 185
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
Hover for explanation

Binary data

It may be the case that a field value is designed to carry arbitrary binary data. In such cases, the data may happen to contain a SOH character, which would terminate the value early and lead to incorrect parsing of the message. To solve this problem, binary data fields are preceded by a companion field which specifies the length in bytes of the subsequent data. FIX engines can then read the given number of bytes and treat any SOH characters encountered as data, and not as a field delimiter.

95
Tag. Identifies this field as ID 95, which is the RawDataLength field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
3
Field value for tag 95. Indicates RawData will be 3 bytes in length
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
96
Tag. Identifies this field as ID 95, which is the RawData field
=
Tag delimiter. Indicates the end of the tag. Decimal value 61
A␁B
The binary data, which in this case happens to contain the SOH character. Note the data will be parsed correctly, since we know the data is 3 bytes, not 1 byte
Field delimiter. SOH character. Indicates the end of the field value. Decimal value 1
Hover for explanation

For a fully comprehensive explanation, read the full technical standard for FIX TagValue encoding.