forwardSerialized FIX Message   Table of ContentFIX Dialectsforward
Typed FIX messages

Message class represents a generic model of any FIX message, in order to manipulate such a message, you need to check the message type and know what fields exist in this message, all of this is not safe and creates some development complexity, so to simplify the FIX message handling and make this more safe you can use strongly typed message classes instead of the generic Message class. Such typed message classes can be generated by the typed messages generator which is included in the FIX Engine distribution package.

Typed messages generator using

There are two modes in the typed messages generator:

  1. Generation from a standard protocol version, in such case please use the following command line arguments:

    <version> <output_file_path> <header_trailer_generation> [<namespace>]

  2. Generation from a xml dialect file, in such case please use the following command line arguments:

    <filename> <output_file_path> <header_trailer_generation> [<namespace>]

Command line arguments description:
  • version - ProtocolVersion value.
  • filename - Path to a dialect file.
  • output_file_path - Path to a file, where typed messages classes will be saved.
  • header_trailer_generation - Flag, to indicate if the message header and trailer fields generation is required, can be "true" or "false".
  • namespace - Root namespace, this argument is optional.
TypedMessageGenerator.exe FIX44 TypedMessages.cs false
Note Note
If you generate typed messages from a xml dialect file please make sure that each message node has the "name" attribute, please see the current dialect xml schema.

Sending and receiving typed messages

You can send typed messages in a similar way to the Message class, please see the example. In order to receive typed messages please use the

class which is generated with typed messages classes, please see the example. Also the example shows how to create and process repeating groups of typed messages.

using FIXForge.NET.FIX;
using FIXForge.NET.FIX.FIX42;
using FIX42.Application.OrdersAndExecutionsTrade.SingleGeneralOrderHandling;

const string senderCompID = "Acceptor";
const string targetCompID = "Initiator";
const ProtocolVersion version = ProtocolVersion.FIX42;
const string host = "localhost";
const int port = 4500;

Engine engine = Engine.Init(port);

using (Session acceptor =
  new Session(senderCompID, targetCompID, version))
  FIX42.TypedMessageListener typedMessageListener = new FIX42.TypedMessageListener(acceptor);

  typedMessageListener.OrderSingleReceived += new Action<OrderSingle>((order) =>
            Console.WriteLine("Order Single message received:  ClOrdID=" + order.ClOrdID + "; Msg(" + ((Message)order) + ")\n");
            Console.WriteLine("NoAllocs group size: " + order.NoAllocs.Count);

            foreach (FIX42.OrderSingleNoAllocsInstance instance in order.NoAllocs)
                Console.WriteLine("AllocAccount=" + instance.AllocAccount + "; AllocShares=" + instance.AllocShares);



  using (Session initiator =
    new Session(targetCompID, senderCompID, version))
    initiator.LogonAsInitiator(host, Engine.Instance.Settings.ListenPort);

    OrderSingle order = new OrderSingle();

    order.ClOrdID = "Unique identifier for Order as assigned by the buy-side";
    order.HandlInst = FIX42.HandlInst.AutomatedExecutionNoIntervention;
    order.Symbol = "Ticker symbol";
    order.Side = FIX42.Side.Buy;
    order.TransactTime = DateTime.UtcNow;
    order.OrdType = FIX42.OrdType.Market;
    order.OrderQty = 10000;

    //NoAllocs repeating group addition.
    FIX42.OrderSingleNoAllocsInstance orderSingleNoAllocsInstance1 = order.NoAllocs.CreateNew();
    orderSingleNoAllocsInstance1.AllocAccount = "AllocAccount1";
    orderSingleNoAllocsInstance1.AllocShares = 10;
    FIX42.OrderSingleNoAllocsInstance orderSingleNoAllocsInstance2 = order.NoAllocs.CreateNew();
    orderSingleNoAllocsInstance2.AllocAccount = "AllocAccount2";
    orderSingleNoAllocsInstance2.AllocShares = 20;



    // Continues the message exchange.

    // Done with messaging.