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.
Install the tool
Section titled “Install the tool”uv tool install refix-cliThis installs a prebuilt binary. With a Rust toolchain, cargo install refix-cli builds it from source.
Generate the code
Section titled “Generate the code”refix codegen venue.xml --python venue.py --rust venue.rsGive --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.
Other FIX versions
Section titled “Other FIX versions”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:
refix codegen FIX43.xml --python fix43.py --rust fix43.rsFrom 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:
refix codegen FIX50SP2.xml --transport FIXT11.xml --python fix50sp2.py --rust fix50sp2.rsThis 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.
Use the module
Section titled “Use the module”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 refixfrom 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)Put venue.rs in src/ and declare the module. It needs the refix-message crate, so run
cargo add refix-message.
#[allow(dead_code)]mod venue;
use refix::message::LogReader;use venue::{DIALECT, Message};
fn main() -> Result<(), Box<dyn std::error::Error>> { let mut reader = LogReader::new(DIALECT, None); reader.feed(&std::fs::read("session.log")?); for record in reader.finish() { if let Message::NewOrderSingle(order) = Message::from_raw(record.message) { println!("{:?} {:?}", order.cl_ord_id()?, order.desk_id()?); } } Ok(())}Without #[allow(dead_code)], a binary gets a warning for each generated item it does not use.
The module is used like the FIX 4.4 package in Typed messages.
How names are derived
Section titled “How names are derived”| 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
Nin front.2_DAYSbecomesN_2_DAYSin Python andN2Daysin Rust. - An enum with the same name as a message gets
Enumon the end, such asSecurityStatusEnum. - Two values of one field with the same description are numbered, such as
EURIBORandEURIBOR_2in Python, andEuriborandEuribor2in Rust.
Warnings and errors
Section titled “Warnings and errors”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'