Documentation for QuickFIX/n

Creating An Application

Get Your DLLs

Starting with v1.9.0, your project will need at least 2 QuickFIX/n dlls:

All of these are in the release zip, or available via NuGet packages. See Downloads.

(If you built QF/n from source, then you'll find these DLLs in Messages\FIX\bin\)

Most applications only need to support one FIX version.

Creating Your Application

Creating a FIX application is easy; simply implement an IApplication:

public class MyQuickFixApp : IApplication
{
    public void FromApp(Message msg, SessionID sessionID) { }
    public void OnCreate(SessionID sessionID) { }
    public void OnLogout(SessionID sessionID) { }
    public void OnLogon(SessionID sessionID) { }
    public void FromAdmin(Message msg, SessionID sessionID) { }
    public void ToAdmin(Message msg, SessionID sessionID) { }
    public void ToApp(Message msg, SessionID sessionID) { }
}

These methods will be called on QuickFIX/n events. We'll explain what each callback does next.

Application Callbacks

The callbacks in a QuickFIX/n application notify us of events: when a counterparty logs on, when admin messages are sent, and most importantly, when application messages are received.

Initiators and Acceptors

QuickFIX/n implements both the initiator and acceptor pattern in FIX.

Initiator is the FIX term for client — we use an Initiator when we are connecting to another party.

Acceptor is the FIX term for server — we use an Acceptor when other parties are connecting to us.

Creating Our Application

Putting it all together, we implement the IApplication interface then instantiate a ThreadedSocketAcceptor:

using QuickFix;
using QuickFix.Logger;
using QuickFix.Store;

public class MyQuickFixApp : IApplication
{
    public void FromApp(Message msg, SessionID sessionID) { }
    public void OnCreate(SessionID sessionID) { }
    public void OnLogout(SessionID sessionID) { }
    public void OnLogon(SessionID sessionID) { }
    public void FromAdmin(Message msg, SessionID sessionID) { }
    public void ToAdmin(Message msg, SessionID sessionID) { }
    public void ToApp(Message msg, SessionID sessionID) { }
}

public class MyApp
{
    static void Main(string[] args)
    {
        SessionSettings settings = new SessionSettings(args[0]);
        IApplication myApp = new MyQuickFixApp();
        IMessageStoreFactory storeFactory = new FileStoreFactory(settings);
        ILogFactory logFactory = new FileLogFactory(settings);
        ThreadedSocketAcceptor acceptor = new ThreadedSocketAcceptor(
            myApp,
            storeFactory,
            settings,
            logFactory);

        acceptor.Start();
        while (true)
        {
            System.Console.WriteLine("o hai");
            System.Threading.Thread.Sleep(1000);
        }
        acceptor.Stop();
    }
}

Please view the Receiving Messages tutorial to see how to implement type safe message callbacks. This is highly recommended.

Switching this to an Initiator is as simple as swapping out the ThreadedSocketAcceptor class for the SocketInitiator class.

The IMessageStore keeps a record of all outgoing messages for FIX session level messaging. We could implement our own store by implementing the IMessageStoreFactory interface.

There are a few options for logging, with FileLogFactory probably being the most useful. We could also implement our own logger by implementing the ILogFactory interface.