Question

I use quickFixEngine and want to use ConfigurationSection for all the engion setting instead the setting.txt file. however I am not sure how to Initialize the SessionSettings with the setting.

I created a "SessionConfiguration" with all the needed properties. After loading the section I try to convert it to Stream and call QuickFix.SessionSettings(Stream) with the created Stream.

I it not work for me....

Thank you.

Was it helpful?

Solution

You will have to change how the underlying stream is being read. Only changing the input method doesn't help. Quickfix is implemented to read the stream in a way by which the configuration settings are arranged in the configuration file. You will get an error if you try to put configuration fields at the wrong place. It shows the stream expects fields only where it has been asked to. You can download the source code and implement your own stream reading mechanism behind it.

OTHER TIPS

If you attempt to not load the SessionSettings from a file, then you may want to define the settings programmatically with the help of a QuickFix.Dictionary, instead with a stream. In C# it works like this:

You initialize your settings:

SessionSettings settings = new SessionSettings();

Then, instantiate a QuickFix.Dictionary and fill it with settings, first with Default, then with Session settings:

    QuickFix.Dictionary defaultDic = new QuickFix.Dictionary();

        defaultDic.SetString("ConnectionType","initiator");
        defaultDic.SetString("ReconnectInterval", "5");
        defaultDic.SetString("FileStorePath", @"../../../FixInitiator/spec/fix/fileStore");
        defaultDic.SetString("FileLogPath", "log");
        defaultDic.SetString("StartTime", "00:00:00");
        defaultDic.SetString("EndTime", "00:00:00");
        defaultDic.SetBool("UseDataDictionary", true);
        defaultDic.SetString("DataDictionary", @"../../../FixInitiator/spec/fix/FIX44.xml");
        defaultDic.SetString("SocketConnectHost", "127.0.0.1");
        defaultDic.SetString("SocketConnectPort", "5001");
        defaultDic.SetString("LogoutTimeout", "5");
        defaultDic.SetBool("ResetOnLogon", true);
        defaultDic.SetBool("ResetOnDisconnect", true);

        settings.Set(defaultDic);


        QuickFix.Dictionary dic = new QuickFix.Dictionary();

        dic.SetString("BeginString", "FIX.4.4");
        dic.SetString("SenderCompID", user);     // user is a string with stored userName
        dic.SetString("TargetCompID", "ServerAcceptor");
        dic.SetString("HeartBtInt", "10");


        SessionID sID = new SessionID("FIX.4.4", user, "ServerAcceptor");
        settings.Set(sID, dic);

When you set the respective setting, you need to use the correct SetType for each setting. I hope this helps.

If by

"instead the setting.txt file"

you mean that you want to create the settings in your code it is possible to use a FIX::SessionSettings object constructed with a default constructor and then set settings via the setstring() method. If you wish to add sessions you can do so by defining a new FIX::Dictionary object and then use setstring() to set the settings. Then you add each session using a new FIX::SessionID object:

FIX::SessionID* myID = new FIX::SessionID("FIX.4.1", "sender_id", "target_id");

and

settings.set(*myID, *myDictionary);

pushes the new dictionary on to the SessionSettings stack. This is a great way to dynamically change settings especially when you need to use settings from elsewhere.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top