Typed messages
A typed message reads a FIX message through named fields, with no tag numbers. Its code is generated from a FIX dictionary.
- Each message type in the dictionary has its own type, with an accessor for every field the dictionary gives it.
- Values are converted to the field’s type, and a field with a fixed set of values is an enum.
- A repeating group is read as a sequence of instances.
- Messages and values that the dictionary does not list are kept, not rejected.
Choose a dictionary
Section titled “Choose a dictionary”- For standard FIX 4.2 or 4.4, install the
refix-fix42orrefix-fix44package next torefix. - For any other dictionary, such as a venue’s or another FIX version, generate your own module with the command-line tool. Your own dictionary explains how.
The examples on this page use refix-fix44. refix-fix42 and a module generated from your own dictionary are used
the same way, with the names their dictionary gives.
Get typed messages
Section titled “Get typed messages”import refixfrom refix_fix44 import CODEC
for record in refix.decode_log("session.log", CODEC): message = record.messageCODEC comes with every generated module. For a raw message from somewhere else, the module’s from_raw
does the same conversion. Give the module’s DIALECT to the tokenizer or the message stream that reads it.
use refix::message::LogReader;use refix_fix44::{DIALECT, Message};
let mut reader = LogReader::new(DIALECT, None);reader.feed(&std::fs::read("session.log")?);for record in reader.finish() { let message = Message::from_raw(record.message);}Message and DIALECT come with every generated module. Message::from_raw takes a raw message from any
source. Give DIALECT to the reader, tokenizer or message stream that reads it.
Each message is read as the type its MsgType names.
Tell messages apart
Section titled “Tell messages apart”from refix_fix44 import MarketDataSnapshotFullRefresh, NewOrderSingle
match message: case NewOrderSingle(): print("order", message.cl_ord_id) case MarketDataSnapshotFullRefresh(): print("snapshot", message.symbol) case refix.RawMessage(): print("not in the dictionary:", message.get_str(35))A message whose MsgType is not in the dictionary stays a RawMessage.
match Message::from_raw(record.message) { Message::NewOrderSingle(order) => println!("order {:?}", order.cl_ord_id()?), Message::MarketDataSnapshotFullRefresh(snapshot) => { println!("snapshot {:?}", snapshot.symbol()?); } Message::Unrecognized(raw) => println!("not in the dictionary: {raw}"), _ => {}}A message whose MsgType is not in the dictionary is a Message::Unrecognized holding the raw message.
Read fields
Section titled “Read fields”The examples read this order:
8=FIX.4.4|9=145|35=D|49=BUYSIDE|56=VENUE|34=3|52=20261103-09:30:36|11=ORDER-1|1=ACC-7731|55=ACME|54=1|60=20261103-09:30:36.250|40=2|44=101.25|38=100|5001=desk-4|10=228order.cl_ord_id # 'ORDER-1'order.side # <Side.BUY: '1'>order.ord_type # <OrdType.LIMIT: '2'>order.price # Decimal('101.25')order.order_qty # Decimal('100')order.transact_time # datetime(2026, 11, 3, 9, 30, 36, 250000, tzinfo=timezone.utc)order.text # NoneA field that is absent reads as None, and a value that cannot be converted raises InvalidValueError.
Timestamps and times also have a property ending in _ns, such as transact_time_ns, that gives nanoseconds
as an int.
let id = order.cl_ord_id()?; // Some("ORDER-1")let side = order.side()?; // Some(Side::Buy)let ord_type = order.ord_type()?; // Some(OrdType::Limit)let price = order.price()?; // Some(101.25)let qty = order.order_qty()?; // Some(100)let time = order.transact_time()?; // Some(2026-11-03 09:30:36.250 UTC)let text = order.text()?; // NoneA field that is absent reads as Ok(None), and a value that cannot be converted is an Err.
Each accessor is named after its field in the dictionary, in snake case.
from refix_fix44 import Side
order.side is Side.BUY # Trueorder.side.name # 'BUY'order.side.value # '1'A value the dictionary does not list reads as an Unrecognized from refix.enums, which holds it in value.
use refix_fix44::Side;
match order.side()? { Some(Side::Buy) => println!("buy"), Some(Side::Sell) => println!("sell"), Some(Side::Unrecognized(value)) => println!("not in the dictionary: {value}"), _ => {}}A value the dictionary does not list reads as the enum’s Unrecognized variant, which holds it.
Header and trailer
Section titled “Header and trailer”order.header.sender_comp_id # 'BUYSIDE'order.header.msg_seq_num # 3order.header.sending_time # datetime(2026, 11, 3, 9, 30, 36, tzinfo=timezone.utc)let header = order.header();let sender = header.sender_comp_id()?; // Some("BUYSIDE")let seq = header.msg_seq_num()?; // Some(3)The trailer’s fields are read the same way from trailer.
Repeating groups
Section titled “Repeating groups”A group is named after its count field without the No, so NoMDEntries (268) is md_entries. This market data
snapshot has two entries:
8=FIX.4.4|9=125|35=W|49=VENUE|56=BUYSIDE|34=9|52=20261103-09:30:37|262=REQ-1|55=ACME|268=2|269=0|270=101.20|271=500|269=1|270=101.30|271=300|10=216for entry in snapshot.md_entries: print(entry.md_entry_type.name, entry.md_entry_px, entry.md_entry_size)BID 101.20 500OFFER 101.30 300The group is a tuple of instances, and is empty when the group is absent.
for entry in &snapshot.md_entries()? { let (Some(kind), Some(price), Some(size)) = (entry.md_entry_type()?, entry.md_entry_px()?, entry.md_entry_size()?) else { continue; }; println!("{kind:?} {price} {size}");}Bid 101.20 500Offer 101.30 300The group also has len, is_empty and get, and is empty when the group is absent.
A group inside a group is read the same way from each instance.
Fields outside the dictionary
Section titled “Fields outside the dictionary”The raw message behind a typed one reads any field by tag, such as the custom 5001 in the order above.
order.raw.get_str(5001) # 'desk-4'Printing a typed message shows its name and wire form, such as NewOrderSingle(8=FIX.4.4|9=145|35=D|...).
use refix::message::Tag;
let desk = order.raw().get_str(Tag(5001))?; // Some("desk-4")Printing a typed message with {:?} shows its name and wire form, such as
NewOrderSingle(8=FIX.4.4|9=145|35=D|...). With {} it shows the wire form alone.