FAST Coding Templates Table of Content Using FIXML Converter
 Using dialect-independent FAST mode

Using dialect-independnt FAST mode.

Understanding of dialect-independent mode

The following notes belonged to the FAST decoder (Decoder class) but all the same considerations are applicable to FAST Encoder (Encoder) as well.

Normally initialization of FAST decoder needs to prepare two XML files: the FAST template itself and FIX dialect. First one describes rules which are applied to binary data and the second one describes allowed structures of messages. Each one message consists of fields and each field has literal ("name") and numeric ("id" or "tag") attributes attached. These attributes defined in the mentioned XML:

• FIX dialect always defines both attributes, 'tag' and 'name'. For instance: <Field name="timestamp" tag="5004"/>

• FAST template should define at least one of them: 'id' or 'name' (for instance: <uInt32 name="timestamp" /> or <uInt32 id="5004" />). The attribute omitted in FAST-template is retrieved by content of the accorded FIX dialect.

Here is an important point: each name has to be mapped to the unique number and vice versa. That's why it is possible to retrieve name by the numeric id and numeric id by the name.

Dialect-independent mode is an approach where only one XML document is used - the FAST template itself. The FIX dialect becomes generated on the base of FAST template content and someone particular FIX protocol version which used as a "base dialect". Since standard FIX protocol descriptions are incorporated within the FIX Engine this approach significantly simplifies usage of the FAST decoder. Also generated dialect usually works slightly faster than separately defined one. User should just prepare a proper FAST template (see \ref fastDialectIndependent_Template) and have to specify the correct version of base FIX protocol (FIX 4.4, FIX 5.0 SP1, etc.). It is possible to omit the choice of the FIX protocol, but note that FIX 4.0 will be used by default, that in turn could affect the compatibility between FIX-messages retrieved from the decoder and FIX-messages provided by a particular provider. The base dialect defines how the resulted FIX message will be exposed in string representation and which representations could be successfully parsed. In particular, this affects the value of tag 8: "8=FIX4.4" for FIX 4.4, "8=FIXT.1.1" for FIX 5.0 and above, etc. That's why the base protocol has to be chosen carefully.

Identifier of the generated FIX dialect will be created within one of two ways:

• MD5 hash of composition between FAST template content and base FIX protocol version. That technics gives hard-to-read identifiers like: "880AF228D17DEA2E3AD6F6D31DC697AE" but a reliably identifies pair of the FAST template and base FIX version and warrantizes prevention of conflicts.

• Use someone user-provided human-readable identifier. In this case, the user is responsible to track that identifier provided doesn't conflict with other ones.

The generated dialect is accessible after the creation of appropriate FAST tool using Dialect property. It is possible to retrieve the identifier of the dialect and use it to subsequent initialization of Dialect instances.

These approaches are illustrated below.

Following snippets illustrate the usage of the OnixS::FIX::FAST::Decoder class but all the same considerations are applicable to OnixS::FIX::FAST::Encoder and OnixS::FIX::FAST::EventBasedDecoder. Instructions for the Engine initialization are omitted also.

Create a decoder in the simplest way using FIX 4.0 as base dialect:

C#
using FIXForge.FIX.FAST;

bool decodeEachMessageIndependently = true;
InputDataTraits inputDataTraits = InputDataTraits.CompleteMessagesOnly;

// FIX40 is specified implicitly
Decoder decoder = new Decoder(fastTemplates, decodeEachMessageIndependently, inputDataTraits);

Create decoder using particular FIX version (FIX 5.0) as base dialect:

C#
using FIXForge.FIX;
using FIXForge.FIX.FAST;

bool decodeEachMessageIndependently = true;
InputDataTraits inputDataTraits = InputDataTraits.CompleteMessagesOnly;
ProtocolVersion version = ProtocolVersion.FIX50;

Decoder decoder = new Decoder(version, fastTemplates, decodeEachMessageIndependently, inputDataTraits);

Create decoder using particular FIX version (FIX 5.0) as base dialect and provide custom dialect name:

C#
using FIXForge.FIX;
using FIXForge.FIX.FAST;

bool decodeEachMessageIndependently = true;
InputDataTraits inputDataTraits = InputDataTraits.CompleteMessagesOnly;
ProtocolVersion version = ProtocolVersion.FIX50;
string customDialectId = "MyDialect_50";

Decoder decoder = new Decoder(version, fastTemplates, customDialectId, decodeEachMessageIndependently, inputDataTraits);

Accessing generated dialect and recreating it in separate context:

C#
string generatedDialectId; // Assume global variable

using FIXForge.FIX;
using FIXForge.FIX.FAST;

bool decodeEachMessageIndependently = true;
InputDataTraits inputDataTraits = InputDataTraits.CompleteMessagesOnly;
ProtocolVersion version = ProtocolVersion.FIX50;

Decoder decoder = new Decoder(version, fastTemplates, decodeEachMessageIndependently, inputDataTraits);
generatedDialectId = decoder.Dialect.Id;

// ..

// That is exactly the same dialect as it was used for decoder.
// It is correspond to mytemplate.xml content and FIX 5.0 base version.
Dialect dialect = new Dialect(generatedDialectId);

Preparing FAST-template to use within the dialect-independent mode

The FAST template should satisfy the following requirements:

1. Each one field definition should contain both attributes: "id" and "name". In particular cases "id" could be missed if corresponding name present within the chosen base dialect.

2. It is possible to have several definitions for the single message type but the particular name should specify either simple field or sequence in all occurrences. The field type, FAST operator and other parts of FAST specification has no matter.

Correct

Wrong

<template id="100" name="Msg1">
<int32 name="Price" id="5200"><copy/></int32>
<int32 name="Amount" id="5201"/>
</template>

<template id="105" name="Msg2">
<decimal name="Price" id="5200"><default/></decimal>
<int32 name="Amount" id="5201"><delta/></int32>
</template>

<!-- Template with simple fields -->
<template id="100" name="Msg1">
<int32 name="NoProducts" id="5300"><copy/></int32>
<string name="Products" id="5301"><copy/></string>
</template>

<!-- Template with sequence -->
<template id="105" name="Msg2">
<sequence name="Products" id="5301">
<length name="NoProducts" id="5300">
</sequence>
</template>