Skip to main content

FIX : Custom messages and fields

 Defining custom FIX protocol messages and custom fields involves extending the standard FIX protocol with your own message types and fields. These customizations are often necessary to support specific business requirements that are not covered by the standard FIX specification.

Here’s a detailed guide on how to define both custom messages and fields in the FIX protocol:


1. Defining Custom FIX Protocol Fields

Steps to Define Custom Fields:

  1. Choose a Custom Tag Number:

    • The FIX protocol assigns tag numbers to fields, with the range 5000 and above typically being used for custom or proprietary fields.
    • Ensure that the tag number you choose does not conflict with the standard FIX field tags (i.e., 1–4999).
  2. Define the Field Name and Description:

    • Field Name: A descriptive name for the field (e.g., CustomOrderID, TraderNote).
    • Tag Number: The number associated with the custom field (e.g., 5500).
    • Data Type: Specify the data type of the field (e.g., String, Integer, Date).
    • Field Description: Clearly describe the purpose of the field.
  3. Example Custom Field Definition:

    • Tag: 5500
    • Name: CustomOrderID
    • Type: String
    • Description: A unique identifier for the custom order used internally by the trading system.

Example of Custom Field in a FIX Message:

8=FIX.4.2|9=74|35=D|49=SenderCompID|56=TargetCompID|34=123|5500=OrderABC123|10=154|

Here, the custom field 5500 (CustomOrderID) is sent with the value OrderABC123.


2. Defining Custom FIX Protocol Messages

Steps to Define Custom Messages:

  1. Define a New Message Type:

    • Each FIX message consists of a set of fields (tags) and has a Message Type identified by a specific MsgType. To create a custom message, you need to assign a new MsgType identifier.
    • Custom message types are typically assigned tag numbers in the range of Z to AZ or from the extended custom tag range (e.g., U1, U2).
  2. Create a Message Definition:

    • MsgType: This is the unique identifier for your custom message.
    • Fields: Define the tags and fields that make up your custom message. These can include both standard and custom fields.
    • Sequence and Structure: Define the order in which fields will appear in the message.
  3. Define the Message Description and Usage:

    • Message Name: A meaningful name for the custom message (e.g., CustomOrderMessage).
    • Purpose: Describe the purpose of the custom message.
    • Tags/Fields: List the tags and their corresponding fields used in the message.

Example Custom Message Definition:

  • MsgType: U1 (custom message type)
  • Message Name: CustomOrderMessage
  • Tags/Fields:
    • 35=U1 (indicating the custom message type)
    • 5500=OrderABC123 (custom field for order ID)
    • 53=1 (standard FIX field for order side, e.g., buy/sell)
    • 54=1 (standard FIX field for quantity)
    • 38=1000 (standard FIX field for quantity of the order)

3. Example of Custom FIX Message Using Custom Fields:

Here’s an example of how you might send a custom message with a custom field in a FIX message:

8=FIX.4.2|9=105|35=U1|49=SenderCompID|56=TargetCompID|34=123|5500=OrderABC123|53=1|54=1|38=1000|10=154|

Explanation:

  • 35=U1: This indicates a custom message type (U1).
  • 5500=OrderABC123: This is the custom field CustomOrderID with the value OrderABC123.
  • 53=1: This is the standard Side field, where 1 might mean a buy order.
  • 54=1: This represents the quantity field, here with a value of 1000.
  • 38=1000: This is the standard Quantity field in FIX, indicating the size of the order.

4. Implementation and Configuration

After defining your custom messages and fields, you will need to:

  1. Update FIX Engine Configuration:

    • Ensure that the FIX engine or parser you are using understands your custom tags and message types.
    • This could mean updating the FIX engine’s configuration files to include the new message types and custom fields.
  2. Custom Message Parsing Logic:

    • You may need to write custom parsers or message handlers to interpret your custom messages and fields. Ensure that both encoding and decoding functions support your custom message structure.
  3. Communication with Counterparties:

    • When using custom fields and messages, ensure that both your side and your counterparties agree on the structure, tags, and message types. This avoids potential issues in message interpretation.
    • Document the custom message types and field definitions and share them with anyone who needs to communicate with your system via FIX.

5. Example of Full Process:

1. Define Custom Field:

  • Tag: 5500
  • Name: CustomOrderID
  • Type: String
  • Description: Internal unique identifier for orders.

2. Define Custom Message:

  • MsgType: U1
  • Name: CustomOrderMessage
  • Fields:
    • 5500=OrderABC123
    • 53=1 (Buy)
    • 54=1 (Quantity)
    • 38=1000

3. Send Message:

8=FIX.4.2|9=105|35=U1|49=SenderCompID|56=TargetCompID|34=123|5500=OrderABC123|53=1|54=1|38=1000|10=154|

By following these steps, you can successfully define and implement custom FIX protocol fields and messages that are specific to your application’s needs.

Comments

Popular posts from this blog

FIX protocol interview questions : Part 1 - Admin/Session

Well, I just felt a need that key FAQs in FIX be documented, so that can be used for a variety of purposes, primarily during interviews to gauge a candidate. I have tried to be correct to the max, but do not guarantee it. This is what is best to my knowledge, and its good to cross check things with the FIX site and documentation available there. 1. What is buy side and what is sell side ? Sell side is the one who earns brokerage. Buy side is the one who pays brokerage. buy side (institutions) sell side (brokers/dealers) 2. What is the latest FIX version in market now? Its FIX 5.0 SP2. Something called FIXT.1.1 is also coming. 3. What is FIXML? FIXML is a structured, validated Extensible Markup Language (XML) derived grammar that is encapsulated within the standard FIX message. This format leaves the FIX session handling intact and minimizes the impact to existing implementations. As an XML-derived language, FIXML messages can be validated by standard parsers and take advantage of a fle...

what is a core dump

 A core dump (or core file ) is a file that captures the memory contents of a running process at a particular point in time, typically when the process crashes or encounters a serious error, such as a segmentation fault or illegal instruction. What is a core dump? It is essentially a snapshot of a process’s memory, including the call stack, memory allocations, and the state of the program at the time of the crash. It helps developers analyze the cause of a crash by examining the state of the program when the error occurred. Why does a core dump occur? A core dump typically happens when a process encounters a fatal error that causes it to terminate unexpectedly. This might include: Segmentation faults (segfaults): Trying to access memory that the process is not allowed to. Illegal instructions: Executing invalid machine instructions. Memory access violations: Trying to access memory in a way that is not allowed (e.g., reading from or writing to protected memory). Un...

std::unordered_map problems

 The std::unordered_map in C++ is a powerful container that provides fast access to key-value pairs with average constant-time complexity ( O(1) ) for lookups, inserts, and deletions. However, like any data structure, it has its potential issues, trade-offs, and limitations. Here are some common problems and limitations associated with std::unordered_map : 1. Unpredictable Iteration Order Problem: The order of elements in an unordered_map is not guaranteed. It depends on the internal hash table implementation and the distribution of hash values. Impact: This makes std::unordered_map unsuitable for use cases where the order of elements matters, such as when you need to traverse the elements in a specific order. Example: cpp Copy std::unordered_map< int , std::string> map; map[ 1 ] = "one" ; map[ 2 ] = "two" ; map[ 3 ] = "three" ; // The order in which elements are iterated is not guaranteed for ( auto & entry : map) { std::cout ...