forwardEncoding and Decoding Data using FAST   Table of ContentUsing dialect-independent FAST modeforward
FAST Coding Templates

Both Encoder and Decoder constructors require the string that contains the XML-based descriptions of coding rules that are called FAST templates.

FAST Template

A FAST template represents an XML-based description of encoding and decoding rules in accordance with the FAST specification.

Template identifier (Template ID) is assigned for each FAST template which uniquely identifies the encoding/decoding rules.

Note Note
More than one FAST template can be used to encode the same FIX message type, so the Template ID is supplied as an argument of the Encode(Message, Int32) method.
Example

The following example represents a typical FAST template structure:

<?xml version="1.0" encoding="utf-8"?>
<templates>
  <template name="Market Data - Incremental Refresh (X)" id="88">
    <uInt32 name="BodyLength" id="9"/>
    <string name="MessageType" id="35">
      <constant value="X" />
    </string>
    <string name="SenderCompID" id="49">
      <copy/>
    </string>
    <string name="TargetCompID" id="56">
      <copy/>
    </string>
    <uInt64 name="MsgSeqNum" id="34">
      <increment value="1"/>
    </uInt64>
    <string name="SendingTime" id="52">
      <tail/>
    </string>
    <string name="PosDupFlag" id="43" presence="optional">
      <default/>
    </string>
    <sequence name="MDEntries">
      <length name="NoMDEntries" id="268"/>
      <string name="MDUpdateAction" id="279"/>
      <string name="Symbol" id="55"/>
    </sequence>
    <string name="CheckSum" id="10"/>
  </template>
</templates>
Field Types

Following field types are supported:

Field TypeDefinition ExampleNotes
Signed 32-bit Integer <int32 name="MDEntrySize" id="271" presence="optional">

Min value: -2147483648.

Max value: 2147483647.

Unsigned 32-bit Integer <uInt32 name="BodyLength" id="9"/>

Min value: 0.

Max value: 4294967295.

Signed 64-bit Integer <int64 name="MinQty" id="110"/>

Min value: -9223372036854775808.

Max value: 9223372036854775807.

Unsigned 64-bit Integer <uInt64 name="MsgSeqNum" id="34"/>

Min value: 0.

Max value: 18446744073709551615.

String <string name="SenderCompID" id="49"/> An optional charset attribute can be used to indicate the character set used in the string ("ascii" or "unicode").
Decimal

<decimal name="MDEntryPx" id="270">

<exponent/>

<mantissa/>

</decimal>

Indicates that the field is represented by two parts: an exponent and a mantissa.
Byte Vector <byteVector name="RawData" id ="96" presence="optional"/> Sequence of bytes.
Sequence

<sequence name="NoSecurityAltID" id="454" presence="optional">

<string name="SecurityAltID" id="455"/>

</sequence>

Specifies that the contained group of instructions should be used repeatedly to encode each element (e.g. to encode/decode a FIX Repeating Group).

A sequence can have an associated length field that contains an unsigned integer indicating the number of encoded elements.

The required name attribute identifies the corresponding field in the current FIX message type by the field name.

The optional id attribute identifies the corresponding field in the current FIX message type by the tag number.

The optional presence attribute indicates whether the field is mandatory or optional. If the attribute is not specified, the field is mandatory.

Field Operators

A field, that is not of Sequence type, can have a field operator. The Field Operator specifies an optimization operation for the field.

The following field operators are supported:

Field OperatorDefinition ExampleNotes
Constant

<string name="MessageType" id="35">

<constant value="X"/>

</string>

Specifies that the value of a field will be always the same initial value.

Applicable to all field types.

Default

<string name="PosDupFlag" id="43" presence="optional">

<default="N"/>

</string>

Specifies that the value of a field is either present in the FAST stream or it will be the initial value.

Applicable to all field types.

Copy

<uInt32 name="MDUpdateAction" id="279">

<copy value="1" />

</uInt32>

If the value is present in the stream, it becomes the new previous value, otherwise, the value of the field is the previous value.

Applicable to all field types.

Increment

<uInt32 name="RptSeq" id="83">

<increment />

</uInt32>

If the value is present in the stream, it becomes the new previous value, otherwise, the value of the field is the previous value incremented by one.

Applicable to Integer field types only.

Delta

<int32 name="MDEntrySize" id="271">

<delta />

</int32>

Specifies that a delta value is present in the stream. The field is obtained by combining the delta value with the previous value.

Applicable to Integer, Decimal, String and Byte Vector field types.

Tail

<string name="SendingTime" id="52">

<tail/>

</string>

Specifies that a tail value is present in the stream. The value of the field is obtained by combining the tail value with the previous value.

Applicable to String and Byte Vector fields with constant or increasing value length.

Dictionaries

Field operators may rely on a previous value. The previous values are maintained in named dictionaries. To reset the states of dictionaries (set the state of the previous values to undefined), the Reset() and Reset() methods are used.