Skip to content

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.
  • For standard FIX 4.2 or 4.4, install the refix-fix42 or refix-fix44 package next to refix.
  • 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.

import refix
from refix_fix44 import CODEC
for record in refix.decode_log("session.log", CODEC):
message = record.message

CODEC 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.

Each message is read as the type its MsgType names.

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.

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=228
order.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 # None

A 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.

Each accessor is named after its field in the dictionary, in snake case.

from refix_fix44 import Side
order.side is Side.BUY # True
order.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.

order.header.sender_comp_id # 'BUYSIDE'
order.header.msg_seq_num # 3
order.header.sending_time # datetime(2026, 11, 3, 9, 30, 36, tzinfo=timezone.utc)

The trailer’s fields are read the same way from trailer.

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=216
for entry in snapshot.md_entries:
print(entry.md_entry_type.name, entry.md_entry_px, entry.md_entry_size)
BID 101.20 500
OFFER 101.30 300

The group is a tuple of instances, and is empty when the group is absent.

A group inside a group is read the same way from each instance.

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|...).