Skip to content

Your own dictionary

The refix command-line tool generates typed messages from your own FIX dictionary.

  • It reads a dictionary in QuickFIX’s XML format, with the custom messages, fields, values and groups it defines.
  • It writes a Python module, a Rust module or both, each as a single file.
  • It accepts a dictionary with common defects, and prints a warning for each thing it dropped or changed.
Terminal window
uv tool install refix-cli

This installs a prebuilt binary. With a Rust toolchain, cargo install refix-cli builds it from source.

Terminal window
refix codegen venue.xml --python venue.py --rust venue.rs

Give --python, --rust or both, each with the path of the file to write. Do not edit the generated files. Run the tool again when the dictionary changes.

FIX 4.2 and 4.4 have ready-made packages. For another version, generate a module from QuickFIX’s dictionary for it, found in its spec directory. For FIX 4.0, 4.1 or 4.3:

Terminal window
refix codegen FIX43.xml --python fix43.py --rust fix43.rs

From FIX 5.0 the header, the trailer and the session messages, such as Logon, are in a transport dictionary of their own, FIXT11.xml. Give it with --transport:

Terminal window
refix codegen FIX50SP2.xml --transport FIXT11.xml --python fix50sp2.py --rust fix50sp2.rs

This works for FIX 5.0, 5.0 SP1 and 5.0 SP2. QuickFIX’s FIX50SP2.xml also holds every extension pack released since SP2, so its Python module is about 10 MB and pyright cannot check code that uses it.

Those dictionaries are under the QuickFIX Software License.

In these examples the dictionary gives NewOrderSingle a custom DeskID (5001) field.

Put venue.py where your code can import it. It needs the refix package.

import refix
from venue import CODEC, NewOrderSingle
for record in refix.decode_log("session.log", CODEC):
order = record.message
if isinstance(order, NewOrderSingle):
print(order.cl_ord_id, order.desk_id)

The module is used like the FIX 4.4 package in Typed messages.

In the dictionary Python Rust
Message NewOrderSingle NewOrderSingle NewOrderSingle
Field DeskID desk_id desk_id()
Field SettlCycle settl_cycle settl_cycle()
Its values, as an enum SettlCycle SettlCycle
Value SAME_DAY SettlCycle.SAME_DAY SettlCycle::SameDay
Group NoAllocAccounts alloc_accounts alloc_accounts()

Some names need a change to be valid or unique:

  • A value whose description starts with a digit gets an N in front. 2_DAYS becomes N_2_DAYS in Python and N2Days in Rust.
  • An enum with the same name as a message gets Enum on the end, such as SecurityStatusEnum.
  • Two values of one field with the same description are numbered, such as EURIBOR and EURIBOR_2 in Python, and Euribor and Euribor2 in Rust.

A defect that leaves the dictionary usable is a warning, and the code is still generated.

warning: message 'VenueStatus' has unknown msgcat 'venue', which is read as app
Defect What the tool does
A tag appears twice in one message Keeps the first and drops the rest
A value code is listed twice for one field Keeps the first and drops the rest
A message’s msgcat is not admin or app Reads it as app
The XML declaration is not at the start of the file Ignores it

Any other problem stops the tool with an error that names it.

error: cannot parse 'venue.xml': message 'VenueStatus' references unknown field 'NoSuchField'