{"id":5476,"library":"simplefix","title":"Simple FIX Protocol Implementation","description":"SimpleFIX is a Python library that provides a straightforward implementation of the FIX (Financial Information eXchange) application-layer protocol. It enables the creation, encoding, and decoding of FIX messages. Unlike full-fledged FIX engines, SimpleFIX focuses solely on message handling and does not include functionality for socket communication, session management, recovery, or message persistence. The library is actively maintained, with its latest version being 1.0.17.","status":"active","version":"1.0.17","language":"en","source_language":"en","source_url":"https://github.com/da4089/simplefix","tags":["FIX protocol","financial","trading","message encoding","message parsing","low-level"],"install":[{"cmd":"pip install simplefix","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Supported for Python versions 3.6 through 3.11.","package":"Python","optional":false}],"imports":[{"note":"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.","wrong":"from simplefix import *\nmessage = FixMessage()","symbol":"FixMessage","correct":"import simplefix\nmessage = simplefix.FixMessage()"},{"symbol":"FixParser","correct":"import simplefix\nparser = simplefix.FixParser()"}],"quickstart":{"code":"import simplefix\nimport datetime\n\n# Create a FIX message\nmessage = simplefix.FixMessage()\nmessage.append_pair(8, \"FIX.4.2\") # BeginString\nmessage.append_pair(35, \"D\")    # MsgType - New Order Single\nmessage.append_pair(49, \"SENDER\") # SenderCompID\nmessage.append_pair(56, \"TARGET\") # TargetCompID\nmessage.append_pair(11, \"ORDER123\") # ClOrdID\nmessage.append_pair(21, 1)      # HandlInst\nmessage.append_pair(55, \"IBM\")   # Symbol\nmessage.append_pair(54, 1)      # Side - Buy\nmessage.append_pair(60, datetime.datetime.utcnow(), fix_type=simplefix.FIX_UTC_TIMESTAMP) # TransactTime\nmessage.append_pair(38, 100)    # OrderQty\nmessage.append_pair(40, 1)      # OrdType - Market\n\n# Encode the message\nencoded_message = message.encode()\nprint(f\"Encoded Message: {encoded_message.decode('ascii').replace(chr(1), '|')}\")\n\n# Parse a FIX message\nparser = simplefix.FixParser()\nparser.append_buffer(encoded_message)\n\nparsed_message = parser.get_message()\n\nif parsed_message:\n    print(f\"Parsed MsgType: {parsed_message.get(35).decode('ascii')}\")\n    print(f\"Parsed Symbol: {parsed_message.get(55).decode('ascii')}\")\nelse:\n    print(\"No complete message found in buffer.\")","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade 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)`.","message":"A 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.","severity":"breaking","affected_versions":">=1.0.17"},{"fix":"Review 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.","message":"Version 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.","severity":"breaking","affected_versions":">=1.0.7"},{"fix":"Be 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.","message":"While `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.","severity":"gotcha","affected_versions":"All"},{"fix":"If 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)`","message":"The FIX standard prohibits empty (zero-length) values. By default, `FixParser` will raise an `EmptyValueError` if it encounters such a field during parsing.","severity":"gotcha","affected_versions":"All"},{"fix":"Always 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`.","message":"Prior 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).","severity":"gotcha","affected_versions":"<1.0.8 (buggy), >=1.0.8 (silently fails)"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}