Tools :: Typed Messages Generator

Typed messages generator

Description

The TmTool generates Java typed wrappers for FIX messages based on either:

  • a FIX dialect XML file;
  • a standard FIX version name (for example FIX40, FIX44, FIX50SP2).

Generated sources include message wrappers and helper classes for the selected dialect. The tool can additionally suppress generation of:

  • standard Header/Trailer wrappers;
  • string-based accessors for date/time fields.

This is a command-line tool with the following syntax:

TmTool Dialect PackageName [-h|-H] [-s|-S] OutputDirectory

Where:

  • Dialect - FIX dialect XML file path or standard FIX version name.
  • PackageName - Java package name used in generated source files.
  • -h / -H - suppress Header/Trailer wrapper generation.
  • -s / -S - suppress string-based accessors for date/time and boolean fields.
  • OutputDirectory - existing output directory for generated files. The package directory structure is not created automatically.

Dialect

This parameter defines the source model used for code generation. Supported values:

  • path to a dialect XML file in a format supported by FIX Engine (including custom/vendor dialects);
  • standard FIX dialect/version identifier from the list available in FIX Engine by default (for example FIX40, FIX44, FIX50SP2).

If a standard version name is passed, the built-in dialect is used. If a file path is passed, the XML is loaded and translated to an internal dialect model before generation.

Dialect name matching has priority over file name matching. If an XML file exists with a name equal to a built-in dialect identifier, the built-in dialect is used.

PackageName

This parameter sets the Java package written into generated source files (package ...;). It also controls namespace references for generated typed message classes, enums, listeners, and helper classes.

Important The tool does not create package folder hierarchy automatically.

Header/Trailer wrappers

In this generator, Header/Trailer wrappers are typed accessors for protocol-level fields declared in the dialect Header and Trailer sections. They are generated directly in each message class (there are no separate Header/Trailer wrapper classes).

When Header/Trailer generation is enabled, message classes include accessors for common session fields from these sections, for example BeginString(8), BodyLength(9), MsgType(35), SenderCompID(49), TargetCompID(56), MsgSeqNum(34), SendingTime(52), and CheckSum(10). The generator also excludes duplicates if the same tag is already declared in the message body.

If -h or -H is passed, these Header/Trailer accessors are not generated. Only message-body accessors remain in the resulting typed class. Regardless of the generation mode, all fields remain accessible through the biz.onixs.fix.parser.FixBlock interface.

The FIX engine still treats these tags as transport/session-level fields and updates mandatory outbound values during session processing.

String-based accessors for date/time and boolean fields

FIX transmits date/time and boolean values as strings on the wire. The generator maps selected FIX types to typed helper objects and produces conversion-based accessors.

For FIX 5.0 SP2, the most common convertible types are:

  • Boolean (for example, PossDupFlag(43), PossResend(97), ManualOrderIndicator(1028))
  • LocalMktDate (for example, TradeDate(75))
  • UTCTimestamp (for example, SendingTime(52), TransactTime(60))
  • MonthYear (for example, MaturityMonthYear(200))

Additional supported convertible types include:

  • UTCDateOnly / UTCTimeOnly (for example, MDEntryDate(272), MDEntryTime(273))
  • TZTimeOnly / TZTimestamp (for example, MaturityTime(1079), TZTransactTime(1132))

Typed accessors follow the get<FieldName>(). Reading values uses:

  • boolean for Boolean
  • DateTimeHelper.DateOnly for LocalMktDate and UTCDateOnly
  • DateTimeHelper.TZTimeOnlyInfo for UTCTimeOnly and TZTimeOnly
  • DateTimeHelper.TZTimestampInfo for UTCTimestamp and TZTimestamp
  • DateTimeHelper.MonthYear for MonthYear

Examples of typed reads:

  • boolean possDup = msg.getPossDupFlag();
  • DateTimeHelper.TZTimestampInfo transactTime = order.getTransactTime();
  • DateTimeHelper.DateOnly tradeDate = report.getTradeDate();
  • DateTimeHelper.MonthYear maturity = secDef.getMaturityMonthYear();

By default, conversion-based fields can also have additional raw string methods get<FieldName>AsString().

These methods read the original tag value without conversion and are useful when exact wire formatting must be preserved or parsed later.

If -s or -S is passed, these additional AsString methods are not generated.

OutputDirectory

This parameter defines the root directory where generated .java files are written. The directory must exist before running the tool.

Important

  • the tool does not create package directory hierarchy from PackageName;
  • the directory is not cleaned before generating;
  • existing files with the same names will be overwritten by a new generation run without warning.

Examples:

  • TmTool FIX50SP2 com.acme.fix.generated ./out - generates wrappers for standard FIX 5.0 SP2, including Header/Trailer and string-based accessors.
  • TmTool ./dialects/CustomFIX.xml com.acme.fix.generated -h -s ./out - generates wrappers from a custom dialect XML without Header/Trailer and without string-based accessors for date/time fields.

Usage

Run the script for your OS:

  • Windows: TmTool.bat {parameters}
  • Linux: TmTool.sh {parameters}