Install & Compatibility
Where this runs
tested against v1.0.17 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.016s · 17.9MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 1.6s · import 0.014s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
FixMessage
✓ import simplefix
message = simplefix.FixMessage()
✗ from simplefix import *
message = FixMessage()
While 'from simplefix import *' is supported, the documentation recommends importing the module and using the fully qualified name for clarity and to avoid namespace pollution.
FixParser
✓ import simplefix
parser = simplefix.FixParser()
This quickstart demonstrates how to create a FIX 'New Order Single' message, append various standard fields including a UTC timestamp, encode it into bytes, and then parse it back using the `FixParser`. Standard FIX header tags like BeginString (8), MsgType (35), SenderCompID (49), and TargetCompID (56) are included, along with common order fields.
import simplefix
import datetime
# Create a FIX message
message = simplefix.FixMessage()
message.append_pair(8, "FIX.4.2") # BeginString
message.append_pair(35, "D") # MsgType - New Order Single
message.append_pair(49, "SENDER") # SenderCompID
message.append_pair(56, "TARGET") # TargetCompID
message.append_pair(11, "ORDER123") # ClOrdID
message.append_pair(21, 1) # HandlInst
message.append_pair(55, "IBM") # Symbol
message.append_pair(54, 1) # Side - Buy
message.append_pair(60, datetime.datetime.utcnow(), fix_type=simplefix.FIX_UTC_TIMESTAMP) # TransactTime
message.append_pair(38, 100) # OrderQty
message.append_pair(40, 1) # OrdType - Market
# Encode the message
encoded_message = message.encode()
print(f"Encoded Message: {encoded_message.decode('ascii').replace(chr(1), '|')}")
# Parse a FIX message
parser = simplefix.FixParser()
parser.append_buffer(encoded_message)
parsed_message = parser.get_message()
if parsed_message:
print(f"Parsed MsgType: {parsed_message.get(35).decode('ascii')}")
print(f"Parsed Symbol: {parsed_message.get(55).decode('ascii')}")
else:
print("No complete message found in buffer.")
Debug
Known issues
breakingA checksum calculation bug was fixed in v1.0.17. If your application relies on SimpleFIX to calculate and set the checksum (tag 10), upgrading to v1.0.17 will result in different, correct checksums. Any systems validating checksums against messages produced by older SimpleFIX versions will break.fixUpgrade to v1.0.17. Ensure downstream systems expect correct FIX checksums. If you were intentionally generating incorrect checksums, you might need to manually set tag 10 or use `encode(raw=True)`.
affects: >=1.0.17
breakingVersion 1.0.7 introduced major changes to string/bytes handling for Python 3.x. All received FIX values are now exported as bytes. Input string values are transformed to bytes using UTF-8 encoding (from strings) and ASCII for everything else. If you require a different encoding for input, you must convert your values to bytes manually before appending them.fixReview all string inputs and outputs. Ensure that string inputs are correctly converted to bytes (e.g., using `.encode('utf-8')`) and byte outputs are decoded (e.g., `.decode('ascii')`) if string representation is needed. Use `fix_type=simplefix.FIX_DATA` for fields meant to carry arbitrary binary data. affects: >=1.0.7
gotchaWhile `FixMessage` generally retains the order in which fields are added, crucial FIX header and trailer fields (BeginString (8), BodyLength (9), MsgType (35), Checksum (10)) are always encoded in their mandated positions regardless of the order they were appended.fixBe aware of the FIX standard's ordering requirements. If specific header fields (e.g., MsgSeqNum (34), SendingTime (52)) need to appear after other header fields but before the body, use the `header=True` parameter with `append_pair` (or similar methods) to ensure correct placement during encoding.
affects: All
gotchaThe FIX standard prohibits empty (zero-length) values. By default, `FixParser` will raise an `EmptyValueError` if it encounters such a field during parsing.fixIf you need to parse messages that might contain empty values (e.g., from non-standard or malformed sources), instantiate `FixParser` with `allow_empty_values=True`. This will prevent the exception and return an empty string value instead. `parser = simplefix.FixParser(allow_empty_values=True)`
affects: All
gotchaPrior to v1.0.8, adding a field with a value of `None` could lead to unexpected behavior. Since v1.0.8, attempting to add a field with a `None` value will silently fail (the field will not be added to the message).fixAlways provide a non-`None` value when appending fields. If a field should be absent, do not append it. If a field should represent a 'null' or 'empty' state, use an explicit empty string (e.g., `''`) or a specific FIX null value as appropriate for the tag's type, rather than `None`.
affects: <1.0.8 (buggy), >=1.0.8 (silently fails)
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'simplefix'
The 'simplefix' library is not installed in your Python environment.
fixInstall the library using pip: `pip install simplefix`
TypeError: Field value must be bytes or a SimpleFIX type
FIX protocol fields expect byte strings, but you are providing a Python 3 Unicode string without explicit encoding.
fixEncode your string values to bytes (e.g., UTF-8 or ASCII) before setting them: `message.append_pair(8, 'FIX.4.2'.encode('utf-8'))` simplefix.FixParserError: Invalid CheckSum (expected XXX, got YYY)
The received FIX message's checksum does not match the checksum calculated by simplefix, indicating a malformed or corrupted message.
fixEnsure the incoming FIX message is complete and correctly formatted, or handle this exception gracefully if receiving potentially invalid messages from an external source.
KeyError: 8
You are trying to access a FIX field by its tag number (e.g., tag 8 for BeginString) that does not exist in the parsed message.
fixCheck if the field exists before accessing it using `message.has_field(tag)` or use `message.get_field(tag, default_value)` to provide a fallback.
TypeError: Message field tag must be of type integer.
FIX message tags are integers, but a string or other non-integer type was provided when attempting to add a field using `append_pair()`.
fixEnsure that the first argument to `append_pair()` is an integer representing the FIX field tag.
Upgrade
Version history
1.0.17latest on PyPI · released Sep 12, 2023
Audit
Dependencies
PythonrequiredSupported for Python versions 3.6 through 3.11.