Skip to content
Grant Birchmeier edited this page Dec 5, 2013 · 6 revisions

This FAQ is very young.

You read the tutorial, right?

How can I put a username/password in the Logon message?

In your IApplication, put this in your ToAdmin method:

public void ToAdmin(Message message, SessionID sessionID)
{
    if(message.Header.GetField(Tags.MsgType)==MsgType.LOGON){
        message.SetField(new QuickFix.Fields.Username("batman"));
        message.SetField(new QuickFix.Fields.Password("gotham123"));
    }
}

Can I put custom settings in my config file?

Yes! This is commonly done with usernames/passwords that the app will insert into Logon messages.

Here is some example code showing you how you can loop through all the sessions defined in your settings file and extract a custom setting "Woot" if it is defined in the session:

// Create object from file that you supply
QuickFix.SessionSettings settings = new QuickFix.SessionSettings(file);

// Get all the session IDs
HashSet<SessionID> sids = settings.GetSessions();

// For each session ID, get the session's settings and look for "Woot" key
foreach (SessionID sid in sids)
{
    Console.WriteLine("==SessionID: " + sid.ToString()+"==");
    Dictionary settingsDict = settings.Get(sid);
    if (settingsDict.Has("Woot"))
        Console.WriteLine("Woot=" + settingsDict.GetString("Woot"));
    else
        Console.WriteLine("Does not have Woot");
}

How can I create a Message object from a raw FIX string?

I am continually surprised by how many people want to do this. Where are you guys getting your FIX strings from if not from a live FIX connection?

Anyway, you want Message.FromString(). Use it like follows:

string msgStr = <your message>

var dd = new QuickFix.DataDictionary.DataDictionary();
dd.Load("some/path/FIX44.xml"); // or whatever file

IMessageFactory defaultMsgFactory = new DefaultMessageFactory();

var msg = new QuickFix.FIX44.ExecutionReport();
msg.FromString(msgStr,true,dd,dd,defaultMsgFactory);

(This is lifted from the unit tests, where it's used quite a bit.)

Clone this wiki locally