FIX protocol in run-time

Basic concept

The Fixopedia is a high-level mechanizm for FixMessage manipulation and it is responsible for:

FIX Dictionary

The FixDictionary is a storage of meta-data which describes different versions and dialects of FIX protocol. The format of FixDictionary structure description is XML. FixDictionary allow to dynamically load protocol descriptions. FixDictionary provides following information about FIX protocol elements:

The FixDictionary support following operations with FIX protocol:

Create and start

The FixDictionary object can be created in common way. The FixDictionary allows to modify FIX protocols until it started, all modification actions are prohibited after FixDictionary::start() is called.

For example:

#include "B2BITS_Fixopaedia.h"
#include "B2BITS_FDElement.h"
#include "B2BITS_Fixopaedia_Descriptions.h"

using namespace Fixopaedia;


// Create the FixDictionary 
std::auto_ptr<FixDictionary> dict(new FixDictionary());

// Modification of the FixDictionary 
// ...

// Start the FixDictionary. FixDictionary modification will be prohibited
dict->start();

// Working with the FixDictionary 
// ...


// destruct FixDictionary
dict.reset()

Insert new FIX protocol element

The FixDictionary could be extended with new FIX protocol elements by using FixDictionary::insert() method.

For example:

#include "B2BITS_Fixopaedia.h"
#include "B2BITS_FDElement.h"
#include "B2BITS_Fixopaedia_Descriptions.h"

using namespace Fixopaedia;


// Create the FixDictionary 
std::auto_ptr<FixDictionary> dict(new FixDictionary());
// Retrive the FIX44 protocol
FDElement* protocol = dict->get("\\\\FIX44");

// Get the integer field type
FDTypeInfo* ti = dict->getTypeInfo(FixDictionaryFactory::nameByFDT(FDT_INT));
// Create new description for the integer field with name 'myField' and id = 1000
FieldDescription* fd = FieldDescription::create("myField", 1000, ti, false);
// Register field description in FIX44 protocol
protocol->toProtocolDescriptionPtr()->registerAdditionalDescription(fd);

// Retrive the 'Allocation Instruction Ack' message of the FIX44 protocol
FDElement* msgP = dict->getRootElement()->get("FIX44\\P");

// Insert the 'myField' tag into the 'Allocation Instruction Ack' message (field is not required)
dict->insert(fd, msgP, NULL, NOT_REQUIRED, "", true);

dict->start();
// Working with the FixDictionary 
// ...

Remove existing FIX protocol elements

The FixDictionary allows removing existing FIX protocol elements using the FixDictionary::remove() method.

For example:

#include "B2BITS_Fixopaedia.h"
#include "B2BITS_FDElement.h"
#include "B2BITS_Fixopaedia_Descriptions.h"

using namespace Fixopaedia;


// Create the FixDictionary 
std::auto_ptr<FixDictionary> dict(new FixDictionary());

// The field 'myField' and id = 1000 was added into the 'Allocation Instruction Ack' message

// Get the descriptor of the 1000 tag
FDElement* fP_1000 = dict->get("\\\\FIX44\\P\\T$1000");
assert(fP_1000 != NULL);
assert(1000 == fP_1000->toFieldDescription()->getTag());

FDElements fdeList;
fdeList.push(fP_1000);

// Remove the 'myField' tag from the 'Allocation Instruction Ack' message 
dict->remove(fdeList);

dict->start();
// Working with the FixDictionary 
// ...

Load FIX protocol customization

The FixDictionary allows loading the FIX protocol customization. FIX protocol customization must be in XML format. The FixDictionary::loadXmlFile() method loads FIX protocol customization from file. The FixDictionary::executeXml() method loads FIX protocol customization from string.

For example:

#include "B2BITS_Fixopaedia.h"
#include "B2BITS_FDElement.h"
#include "B2BITS_Fixopaedia_Descriptions.h"

using namespace Fixopaedia;


// Create the FixDictionary 
std::auto_ptr<FixDictionary> dict(new FixDictionary());

// Update FIX protocol from "exampleFIXProtocol.xml" file
dict->loadXmlFile("exampleFIXProtocol.xml");

// FIX41 protocol customization - new tag 386 added into the 'Order Cancel/Replace Request' message
std::string xml2("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
                "<fixdics><update>"
                "<fixdic fixversion=\"4.1\" title=\"FIX 4.1\" date=\"2006/5/11\">"              
                "<fielddic>"
                    "<fielddef tag=\"386\" name=\"field386float\" type=\"float\">"
                "</fielddef>"
                "</fielddic>"
                "<msgdic>"
                    "<msgdef msgtype=\"G\" >"
                        "<field tag=\"386\"/>"
                    "</msgdef></msgdic></fixdic>"
                "</update></fixdics>");
        
// Update the FIXDictionary
dict->executeXml(xml2);

dict->start();
// Working with the FixDictionary 
// ...

Search for the FIX protocol elements

The FixDictionary allows searching the FIX protocol elements using the FixDictionary::query() method. The search criteria are specified by the FIXPath language.

For example:

#include "B2BITS_Fixopaedia.h"
#include "B2BITS_FDElement.h"
#include "B2BITS_Fixopaedia_Descriptions.h"

using namespace Fixopaedia;


// Create the FixDictionary 
std::auto_ptr<FixDictionary> dict(new FixDictionary());

FDElements fdeList;

// Locate the 571 tag in 'Collateral Inquiry' message
bool qres = dict->query("\\\\FIX44\\BB", SEARCH_DEEP, "Type=Field, ID=571", &fdeList);
assert(qres);
assert(1 == fdeList.size());

FIXPath

FixPath is a string, which defines location of partial field in given Fix Message of given Fix protocol. FixPath can be used to locate specified element in FixDictionary. FIXPath grammer is following:

    <FixPath> ::= "\\", <Protocol>, "\", <MessageType>, "\", <PathNode> { , "\", <PathNode> } ;
    <Protocol> ::= Fix protocol version; 
    <MessageType> ::= The type of Fix message; 
    <PathNode> := [<Name>], ["$", <tag>] ; (*) 
    <Name> ::= The name of dictionary entry ('T' for tags and 'G' for groups); 
    <tag> ::= The number of tag for Field or leading tag for Group; 
    <IndexInGroup> ::= The index of partial field in repeating group. (**)(***)

    (*) At least one element '<Name>' or ' "$", <tag>' must be specified.
    (**) IndexInGroup is zero-based.
    (***) IndexInGroup is always ignored by FixDictionary but can be used by dictionary-based applications for selecting partial field in repeating group.

FixPath can be absolute or relative. For absolute path FixDictionary calculates field position starting from dictionary root. For relative path FixDictionary calculates field position starting from current context (f.e. if we got a message from FixDictionary, we can query it fields by relative path, without selecting protocol and message type).

    <RelativePath> ::= ".\", <PathNode> { , "\", <PathNode> } ;

The dictionary element for each iteration is searchig by following way:

  1. Search is always starts from Name.
  2. If dictionary element not found and specifieg Tag, the FixDictionary search element by tag.
  3. If name not specified, the FixDictionary search element by tag.

For example:

\\FIX44\8\$31 - FixDictionary entry for Field with tag 31 in message of type "8" for FIX v4.4; 
\\FIX44\8\ClOrdID - FixDictionary entry for Field with Name "ClOrdID" in message of type "8" for FIX v4.4; 
\\FIX44\8\Instrument\$55 - FixDictionary entry for Field with tag 31 in block "Instrument" (The same result will be for path '\\FIX44\8\$55'); 
.\$25 - FixDictionary entry for Field or Group with tag 25 depending on context.

Generated on Fri Apr 17 12:26:08 2009 for B2BITS FIX Antenna C++ by  doxygen 1.5.6