User Defined Fields

FIX allows users to define fields not defined in the specifications. How can QuickFIX be used to set and get user defined fields? Well one answer would be to use the non-type safe set and get fields like so:

See this code in PYTHON, RUBY
message.setField(6123, "value");
message.getField(6123);

QuickFIX also provides supplies macros for creating typesafe field objects.

See this code in PYTHON, RUBY
#include "quickfix/Field.h"

namespace FIX
{
  USER_DEFINE_STRING(MyStringField, 6123);
  USER_DEFINE_PRICE(MyPriceField, 8756);
}

User defined fields must be declared within the FIX namespace. Now, elsewhere in your application, you can write code like this:

See this code in PYTHON, RUBY
MyStringField stringField("string");
MyPriceField priceField(14.54);

message.setField(stringField);
message.setField(priceField);

message.getField(stringField);
message.getField(priceField);

These macros allow you to define fields of all supported FIX types. Keep in mind you can write fields of any type types as long as you supply a new macro and convertor that can convert your type to and from a string.

USER_DEFINE_STRING( NAME, NUM )
USER_DEFINE_CHAR( NAME, NUM )
USER_DEFINE_PRICE( NAME, NUM )
USER_DEFINE_INT( NAME, NUM )
USER_DEFINE_AMT( NAME, NUM )
USER_DEFINE_QTY( NAME, NUM )
USER_DEFINE_CURRENCY( NAME, NUM )
USER_DEFINE_MULTIPLEVALUESTRING( NAME, NUM )
USER_DEFINE_EXCHANGE( NAME, NUM )
USER_DEFINE_UTCTIMESTAMP( NAME, NUM )
USER_DEFINE_BOOLEAN( NAME, NUM )
USER_DEFINE_LOCALMKTDATE( NAME, NUM )
USER_DEFINE_DATA( NAME, NUM )
USER_DEFINE_FLOAT( NAME, NUM )
USER_DEFINE_PRICEOFFSET( NAME, NUM )
USER_DEFINE_MONTHYEAR( NAME, NUM )
USER_DEFINE_DAYOFMONTH( NAME, NUM )
USER_DEFINE_UTCDATE( NAME, NUM )
USER_DEFINE_UTCTIMEONLY( NAME, NUM )
USER_DEFINE_NUMINGROUP( NAME, NUM )
USER_DEFINE_SEQNUM( NAME, NUM )
USER_DEFINE_LENGTH( NAME, NUM )
USER_DEFINE_PERCENTAGE( NAME, NUM )
USER_DEFINE_COUNTRY( NAME, NUM )