SetString() public method

public SetString ( string key, string val ) : void
key string
val string
return void
        public void ValueEquality()
        {
            QuickFix.Dictionary first  = new QuickFix.Dictionary("Name");
            QuickFix.Dictionary second = new QuickFix.Dictionary("Name");
            Assert.True(first.Equals(second));

            first.SetString("THIRDKEY", "FIRST");
            second.SetString("THIRDKEY", "SECOND");
            Assert.False(first.Equals(second));

            first.SetString("THIRDKEY", "SECOND");
            Assert.True(first.Equals(second));

            first.SetString("FIRSTKEY", "FIRSTVALUE");
            second.SetString("SECONDKEY", "SECONDVALUE");
            Assert.False(first.Equals(second));

            first.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("FIRSTKEY", "FIRSTVALUE");
            Assert.True(first.Equals(second));

            QuickFix.Dictionary third  = new QuickFix.Dictionary("Name1");
            QuickFix.Dictionary fourth = new QuickFix.Dictionary("Name2");
            Assert.False(third.Equals(fourth));
        }
 public void SetGetString()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetString("STRINGKEY1", "STRINGVALUE1");
     d.SetString("STRINGKEY2", "stringvalue2");
     Assert.That(d.GetString("STRINGKEY1"), Is.EqualTo("STRINGVALUE1"));
     Assert.That(d.GetString("STRINGKEY2"), Is.EqualTo("stringvalue2"));
     Assert.That(d.GetString("STRINGKEY2", true), Is.EqualTo("STRINGVALUE2"));
     Assert.Throws <ConfigError>(delegate { d.GetString("STRINGKEY3"); });
 }
 Dictionary CreateSessionConfig(string targetCompID, bool isInitiator)
 {
     Dictionary settings = new Dictionary();
     settings.SetString(SessionSettings.CONNECTION_TYPE, isInitiator ? "initiator" : "acceptor");
     settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N");
     settings.SetString(SessionSettings.START_TIME, "12:00:00");
     settings.SetString(SessionSettings.END_TIME, "12:00:00");
     settings.SetString(SessionSettings.HEARTBTINT, "300");
     return settings;
 }
Beispiel #4
0
 public void SetGetString()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetString("STRINGKEY1", "STRINGVALUE1");
     d.SetString("STRINGKEY2", "stringvalue2");
     Assert.That(d.GetString("STRINGKEY1"), Is.EqualTo("STRINGVALUE1"));
     Assert.That(d.GetString("STRINGKEY2"), Is.EqualTo("stringvalue2"));
     Assert.That(d.GetString("STRINGKEY2", true), Is.EqualTo("STRINGVALUE2"));
     Assert.Throws<ConfigError>(delegate { d.GetString("STRINGKEY3"); });
 }
        public void Merge()
        {
            QuickFix.Dictionary first = new QuickFix.Dictionary();
            first.SetString("FIRSTKEY", "FIRSTVALUE");
            first.SetString("THIRDKEY", "FIRST");

            QuickFix.Dictionary second = new QuickFix.Dictionary();
            second.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("THIRDKEY", "SECOND");

            first.Merge(second);
            Assert.That(first.GetString("FIRSTKEY"), Is.EqualTo("FIRSTVALUE"));
            Assert.That(first.GetString("SECONDKEY"), Is.EqualTo("SECONDVALUE"));
            Assert.That(first.GetString("THIRDKEY"), Is.EqualTo("FIRST"));
        }
Beispiel #6
0
        public void Merge()
        {
            QuickFix.Dictionary first = new QuickFix.Dictionary();
            first.SetString("FIRSTKEY", "FIRSTVALUE");
            first.SetString("THIRDKEY", "FIRST");

            QuickFix.Dictionary second = new QuickFix.Dictionary();
            second.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("THIRDKEY", "SECOND");

            first.Merge(second);
            Assert.That(first.GetString("FIRSTKEY"), Is.EqualTo("FIRSTVALUE"));
            Assert.That(first.GetString("SECONDKEY"), Is.EqualTo("SECONDVALUE"));
            Assert.That(first.GetString("THIRDKEY"), Is.EqualTo("FIRST"));
        }
Beispiel #7
0
        public void setup()
        {
            sessionID = new QuickFix.SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");
            Wipe();

            QuickFix.Dictionary config = new QuickFix.Dictionary();
            config.SetString(QuickFix.SessionSettings.CONNECTION_TYPE, "initiator");
            config.SetString(QuickFix.SessionSettings.DATABASE_STORE_CONNECTION_STRING, connectionString);

            settings = new QuickFix.SessionSettings();
            settings.Set(sessionID, config);
            factory = new QuickFix.DatabaseStoreFactory(settings);
            settings.Set(config);

            store = (QuickFix.DatabaseStore)factory.Create(sessionID, new NullLog());
        }
        public void ValidConfiguration()
        {
            Application app = new NullApplication();
            MessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionFactory factory = new SessionFactory(app, storeFactory);

            SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET");
            Dictionary settings = new Dictionary();
            settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N");
            settings.SetString(SessionSettings.START_TIME, "12:00:00");
            settings.SetString(SessionSettings.END_TIME, "12:00:00");
            settings.SetString(SessionSettings.HEARTBTINT, "30");

            Assert.DoesNotThrow(delegate { factory.Create(sessionID, settings); });
        }
Beispiel #9
0
        public void GetDouble()
        {
            // make sure that QF/n uses the invariant culture, no matter what the current culture is
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

            QuickFix.Dictionary d = new QuickFix.Dictionary();
            d.SetString("DOUBLEKEY1", "12.3");
            d.SetString("DOUBLEKEY2", "987362.987362");
            d.SetString("BADDOUBLEKEY", "AB12.3");
            d.SetString("FOREIGNFORMAT", "44,44");

            Assert.That(d.GetDouble("DOUBLEKEY1"), Is.EqualTo(12.3));
            Assert.That(d.GetDouble("DOUBLEKEY2"), Is.EqualTo(987362.987362));
            Assert.Throws<ConfigError>(delegate { d.GetDouble("DOUBLEKEY3"); });
            Assert.Throws<ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
            Assert.Throws<ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
        }
        public void GetDouble()
        {
            // make sure that QF/n uses the invariant culture, no matter what the current culture is
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

            QuickFix.Dictionary d = new QuickFix.Dictionary();
            d.SetString("DOUBLEKEY1", "12.3");
            d.SetString("DOUBLEKEY2", "987362.987362");
            d.SetString("BADDOUBLEKEY", "AB12.3");
            d.SetString("FOREIGNFORMAT", "44,44");

            Assert.That(d.GetDouble("DOUBLEKEY1"), Is.EqualTo(12.3));
            Assert.That(d.GetDouble("DOUBLEKEY2"), Is.EqualTo(987362.987362));
            Assert.Throws <ConfigError>(delegate { d.GetDouble("DOUBLEKEY3"); });
            Assert.Throws <ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
            Assert.Throws <ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
        }
Beispiel #11
0
        public void SetGetDay()
        {
            QuickFix.Dictionary d = new QuickFix.Dictionary();

            d.SetString("DAY1", "SU");
            d.SetString("DAY2", "MO");
            d.SetString("DAY3", "TU");
            d.SetString("DAY4", "WE");
            d.SetString("DAY5", "TH");
            d.SetString("DAY6", "FR");
            d.SetString("DAY7", "SA");
            Assert.That(d.GetDay("DAY1"), Is.EqualTo(System.DayOfWeek.Sunday));
            Assert.That(d.GetDay("DAY2"), Is.EqualTo(System.DayOfWeek.Monday));
            Assert.That(d.GetDay("DAY3"), Is.EqualTo(System.DayOfWeek.Tuesday));
            Assert.That(d.GetDay("DAY4"), Is.EqualTo(System.DayOfWeek.Wednesday));
            Assert.That(d.GetDay("DAY5"), Is.EqualTo(System.DayOfWeek.Thursday));
            Assert.That(d.GetDay("DAY6"), Is.EqualTo(System.DayOfWeek.Friday));
            Assert.That(d.GetDay("DAY7"), Is.EqualTo(System.DayOfWeek.Saturday));

            d.SetDay("NEXTDAY1", System.DayOfWeek.Sunday);
            d.SetDay("NEXTDAY2", System.DayOfWeek.Monday);
            d.SetDay("NEXTDAY3", System.DayOfWeek.Tuesday);
            d.SetDay("NEXTDAY4", System.DayOfWeek.Wednesday);
            d.SetDay("NEXTDAY5", System.DayOfWeek.Thursday);
            d.SetDay("NEXTDAY6", System.DayOfWeek.Friday);
            d.SetDay("NEXTDAY7", System.DayOfWeek.Saturday);
            Assert.That(d.GetDay("NEXTDAY1"), Is.EqualTo(System.DayOfWeek.Sunday));
            Assert.That(d.GetDay("NEXTDAY2"), Is.EqualTo(System.DayOfWeek.Monday));
            Assert.That(d.GetDay("NEXTDAY3"), Is.EqualTo(System.DayOfWeek.Tuesday));
            Assert.That(d.GetDay("NEXTDAY4"), Is.EqualTo(System.DayOfWeek.Wednesday));
            Assert.That(d.GetDay("NEXTDAY5"), Is.EqualTo(System.DayOfWeek.Thursday));
            Assert.That(d.GetDay("NEXTDAY6"), Is.EqualTo(System.DayOfWeek.Friday));
            Assert.That(d.GetDay("NEXTDAY7"), Is.EqualTo(System.DayOfWeek.Saturday));
        }
Beispiel #12
0
 private void Set(SessionID sessionID, QuickFix.Dictionary settings)
 {
     if (Has(sessionID))
     {
         throw new ConfigError("Duplicate Session " + sessionID.ToString());
     }
     settings.SetString(SessionSettings.BEGINSTRING, sessionID.BeginString);
     settings.SetString(SessionSettings.SENDERCOMPID, sessionID.SenderCompID);
     if (SessionID.IsSet(sessionID.SenderSubID))
     {
         settings.SetString(SessionSettings.SENDERSUBID, sessionID.SenderSubID);
     }
     if (SessionID.IsSet(sessionID.SenderLocationID))
     {
         settings.SetString(SessionSettings.SENDERLOCID, sessionID.SenderLocationID);
     }
     settings.SetString(SessionSettings.TARGETCOMPID, sessionID.TargetCompID);
     if (SessionID.IsSet(sessionID.TargetSubID))
     {
         settings.SetString(SessionSettings.TARGETSUBID, sessionID.TargetSubID);
     }
     if (SessionID.IsSet(sessionID.TargetLocationID))
     {
         settings.SetString(SessionSettings.TARGETLOCID, sessionID.TargetLocationID);
     }
     settings.Merge(defaults_);
     Validate(settings);
     settings_[sessionID] = settings;
 }
Beispiel #13
0
 Dictionary CreateSessionConfig(string targetCompID, bool isInitiator)
 {
     Dictionary settings = new Dictionary();
     settings.SetString(SessionSettings.CONNECTION_TYPE, isInitiator ? "initiator" : "acceptor");
     settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N");
     settings.SetString(SessionSettings.START_TIME, "12:00:00");
     settings.SetString(SessionSettings.END_TIME, "12:00:00");
     settings.SetString(SessionSettings.HEARTBTINT, "300");
     settings.SetString(SessionSettings.SOCKET_CONNECT_HOST, Host);
     settings.SetString(SessionSettings.SOCKET_CONNECT_PORT, ConnectPort.ToString());
     settings.SetString(SessionSettings.SOCKET_ACCEPT_HOST, Host);
     settings.SetString(SessionSettings.SOCKET_ACCEPT_PORT, AcceptPort.ToString());
     return settings;
 }
        public void SetGetDay()
        {
            QuickFix.Dictionary d = new QuickFix.Dictionary();

            d.SetString("DAY1", "SU");
            d.SetString("DAY2", "MO");
            d.SetString("DAY3", "TU");
            d.SetString("DAY4", "WE");
            d.SetString("DAY5", "TH");
            d.SetString("DAY6", "FR");
            d.SetString("DAY7", "SA");
            Assert.That(d.GetDay("DAY1"), Is.EqualTo(System.DayOfWeek.Sunday));
            Assert.That(d.GetDay("DAY2"), Is.EqualTo(System.DayOfWeek.Monday));
            Assert.That(d.GetDay("DAY3"), Is.EqualTo(System.DayOfWeek.Tuesday));
            Assert.That(d.GetDay("DAY4"), Is.EqualTo(System.DayOfWeek.Wednesday));
            Assert.That(d.GetDay("DAY5"), Is.EqualTo(System.DayOfWeek.Thursday));
            Assert.That(d.GetDay("DAY6"), Is.EqualTo(System.DayOfWeek.Friday));
            Assert.That(d.GetDay("DAY7"), Is.EqualTo(System.DayOfWeek.Saturday));

            d.SetDay("NEXTDAY1", System.DayOfWeek.Sunday);
            d.SetDay("NEXTDAY2", System.DayOfWeek.Monday);
            d.SetDay("NEXTDAY3", System.DayOfWeek.Tuesday);
            d.SetDay("NEXTDAY4", System.DayOfWeek.Wednesday);
            d.SetDay("NEXTDAY5", System.DayOfWeek.Thursday);
            d.SetDay("NEXTDAY6", System.DayOfWeek.Friday);
            d.SetDay("NEXTDAY7", System.DayOfWeek.Saturday);
            Assert.That(d.GetDay("NEXTDAY1"), Is.EqualTo(System.DayOfWeek.Sunday));
            Assert.That(d.GetDay("NEXTDAY2"), Is.EqualTo(System.DayOfWeek.Monday));
            Assert.That(d.GetDay("NEXTDAY3"), Is.EqualTo(System.DayOfWeek.Tuesday));
            Assert.That(d.GetDay("NEXTDAY4"), Is.EqualTo(System.DayOfWeek.Wednesday));
            Assert.That(d.GetDay("NEXTDAY5"), Is.EqualTo(System.DayOfWeek.Thursday));
            Assert.That(d.GetDay("NEXTDAY6"), Is.EqualTo(System.DayOfWeek.Friday));
            Assert.That(d.GetDay("NEXTDAY7"), Is.EqualTo(System.DayOfWeek.Saturday));
        }
Beispiel #15
0
        public void SetGetDay()
        {
            QuickFix.Dictionary d = new QuickFix.Dictionary();

            d.SetString("DAY1", "SU");
            d.SetString("DAY2", "MO");
            d.SetString("DAY3", "TU");
            d.SetString("DAY4", "WE");
            d.SetString("DAY5", "TH");
            d.SetString("DAY6", "FR");
            d.SetString("DAY7", "SA");
            Assert.That(d.GetDay("DAY1"), Is.EqualTo(1));
            Assert.That(d.GetDay("DAY2"), Is.EqualTo(2));
            Assert.That(d.GetDay("DAY3"), Is.EqualTo(3));
            Assert.That(d.GetDay("DAY4"), Is.EqualTo(4));
            Assert.That(d.GetDay("DAY5"), Is.EqualTo(5));
            Assert.That(d.GetDay("DAY6"), Is.EqualTo(6));
            Assert.That(d.GetDay("DAY7"), Is.EqualTo(7));

            d.SetDay("NEXTDAY1", 1);
            d.SetDay("NEXTDAY2", 2);
            d.SetDay("NEXTDAY3", 3);
            d.SetDay("NEXTDAY4", 4);
            d.SetDay("NEXTDAY5", 5);
            d.SetDay("NEXTDAY6", 6);
            d.SetDay("NEXTDAY7", 7);
            Assert.That(d.GetDay("NEXTDAY1"), Is.EqualTo(1));
            Assert.That(d.GetDay("NEXTDAY2"), Is.EqualTo(2));
            Assert.That(d.GetDay("NEXTDAY3"), Is.EqualTo(3));
            Assert.That(d.GetDay("NEXTDAY4"), Is.EqualTo(4));
            Assert.That(d.GetDay("NEXTDAY5"), Is.EqualTo(5));
            Assert.That(d.GetDay("NEXTDAY6"), Is.EqualTo(6));
            Assert.That(d.GetDay("NEXTDAY7"), Is.EqualTo(7));
        }
Beispiel #16
0
 public void SetGetDouble()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetDouble("DOUBLEKEY1", 12.3);
     d.SetDouble("DOUBLEKEY2", 987362.987362);
     d.SetString("BADDOUBLEKEY", "AB12.3");
     Assert.That(d.GetDouble("DOUBLEKEY1"), Is.EqualTo(12.3));
     Assert.That(d.GetDouble("DOUBLEKEY2"), Is.EqualTo(987362.987362));
     Assert.Throws <ConfigError>(delegate { d.GetDouble("DOUBLEKEY3"); });
     Assert.Throws <ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
 }
Beispiel #17
0
 public void SetGetDouble()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetDouble("DOUBLEKEY1", 12.3);
     d.SetDouble("DOUBLEKEY2", 987362.987362);
     d.SetString("BADDOUBLEKEY", "AB12.3");
     Assert.That(d.GetDouble("DOUBLEKEY1"), Is.EqualTo(12.3));
     Assert.That(d.GetDouble("DOUBLEKEY2"), Is.EqualTo(987362.987362));
     Assert.Throws<ConfigError>(delegate { d.GetDouble("DOUBLEKEY3"); });
     Assert.Throws<ConfigError>(delegate { d.GetDouble("BADDOUBLEKEY"); });
 }
 public void SetGetBool()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetBool("BOOLKEY1", true);
     d.SetBool("BOOLKEY2", false);
     d.SetString("BADBOOLKEY2", "YO");
     Assert.That(d.GetBool("BOOLKEY1"), Is.True);
     Assert.That(d.GetBool("BOOLKEY2"), Is.False);
     Assert.Throws <ConfigError>(delegate { d.GetBool("BOOLKEY3"); });
     Assert.Throws <ConfigError>(delegate { d.GetBool("BADBOOLKEY2"); });
 }
        public bool StartSession(string strHostName, int nPort, string strSenderCompID, string strTargetCompID, string strPassword)
        {
            try
            {
                if (!IsPortOpen(strHostName, nPort, new TimeSpan(0, 0, 10)))
                {
                    return(false);
                }

                string strAppDirPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

                QuickFix.Dictionary dicConfig = new QuickFix.Dictionary();
                dicConfig.SetString("ConnectionType", "initiator");
                dicConfig.SetDay("StartDay", DayOfWeek.Sunday);
                dicConfig.SetString("StartTime", "00:00:00");
                dicConfig.SetDay("EndDay", DayOfWeek.Saturday);
                dicConfig.SetString("EndTime", "00:00:00");
                dicConfig.SetDouble("HeartBtInt", 20);
                dicConfig.SetDouble("ReconnectInterval", 10);
                dicConfig.SetBool("ResetOnLogout", true);
                dicConfig.SetBool("ResetOnLogon", true);
                dicConfig.SetBool("ResetOnDisconnect", true);
                dicConfig.SetBool("ResetSeqNumFlag", true);
                dicConfig.SetDouble("EncryptMethod", 0);
                dicConfig.SetBool("CheckLatency", false);
                dicConfig.SetString("FileStorePath", strAppDirPath + "/Store/Ctrader_Price");
                dicConfig.SetString("FileLogPath", strAppDirPath + "/Log");
                dicConfig.SetBool("UseDataDictionary", true);
                dicConfig.SetString("DataDictionary", strAppDirPath + "/Settings/FIX44-OneZero.xml");
                dicConfig.SetBool("ScreenLogShowIncoming", false);
                dicConfig.SetBool("ScreenLogShowOutgoing", false);
                dicConfig.SetString("Password", strPassword);

                SessionID           quoteSessionID  = new SessionID("FIX.4.4", strSenderCompID, strTargetCompID);
                QuickFix.Dictionary dicQuoteSession = new QuickFix.Dictionary();
                dicQuoteSession.SetString("SocketConnectHost", strHostName);
                dicQuoteSession.SetDouble("SocketConnectPort", nPort);

                settings = new SessionSettings();
                settings.Set(dicConfig);
                settings.Set(quoteSessionID, dicQuoteSession);

                FileStoreFactory storeFactory = new FileStoreFactory(settings);
                ScreenLogFactory logFactory   = new ScreenLogFactory(settings);
                initiator = new SocketInitiator(this, storeFactory, settings, logFactory);
                initiator.Start();
                return(true);
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
                return(false);
            }
        }
Beispiel #20
0
 public void SetGetLong()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetLong("LONGKEY1", 12);
     d.SetLong("LONGKEY2", 987362);
     d.SetString("BADLONGKEY", "AB12");
     Assert.That(d.GetLong("LONGKEY1"), Is.EqualTo(12));
     Assert.That(d.GetLong("LONGKEY2"), Is.EqualTo(987362));
     Assert.Throws<ConfigError>(delegate { d.GetLong("LONGKEY3"); });
     Assert.Throws<ConfigError>(delegate { d.GetLong("BADLONGKEY"); });
 }
 public void SetGetLong()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetLong("LONGKEY1", 12);
     d.SetLong("LONGKEY2", 987362);
     d.SetString("BADLONGKEY", "AB12");
     Assert.That(d.GetLong("LONGKEY1"), Is.EqualTo(12));
     Assert.That(d.GetLong("LONGKEY2"), Is.EqualTo(987362));
     Assert.Throws <ConfigError>(delegate { d.GetLong("LONGKEY3"); });
     Assert.Throws <ConfigError>(delegate { d.GetLong("BADLONGKEY"); });
 }
Beispiel #22
0
 public void SetGetBool()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetBool("BOOLKEY1", true);
     d.SetBool("BOOLKEY2", false);
     d.SetString("BADBOOLKEY2", "YO");
     Assert.That(d.GetBool("BOOLKEY1"), Is.True);
     Assert.That(d.GetBool("BOOLKEY2"), Is.False);
     Assert.Throws<ConfigError>(delegate { d.GetBool("BOOLKEY3"); });
     Assert.Throws<ConfigError>(delegate { d.GetBool("BADBOOLKEY2"); });
 }
Beispiel #23
0
        public void Validate()
        {
            SessionSettings settings  = new SessionSettings();
            SessionID       sessionID = new SessionID("FIX.4.2", "SenderCompID", "TargetCompID");

            // ConnectionType not set
            QuickFix.Dictionary dictionary = new QuickFix.Dictionary();
            Assert.Throws <ConfigError>(delegate { settings.Set(sessionID, dictionary); });

            // ConnectionType set to invalid value
            dictionary.SetString(SessionSettings.CONNECTION_TYPE, "badvalue");
            Assert.Throws <ConfigError>(delegate { settings.Set(sessionID, dictionary); });

            // ConnectionType set to valid value
            dictionary.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            Assert.DoesNotThrow(delegate { settings.Set(sessionID, dictionary); });

            // Invalid BeginString
            sessionID = new SessionID("FIX4.2", "SenderCompID", "TargetCompID");
            Assert.Throws <ConfigError>(delegate { settings.Set(sessionID, dictionary); });
        }
        public void TestPersistMessages()
        {
            IApplication app = new NullApplication();
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionFactory factory = new SessionFactory(app, storeFactory);

            SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET");
            Dictionary settings = new Dictionary();
            settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N");
            settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            settings.SetString(SessionSettings.HEARTBTINT, "30");
            settings.SetString(SessionSettings.START_TIME, "12:00:00");
            settings.SetString(SessionSettings.END_TIME, "12:00:00");
            Session session = factory.Create(sessionID, settings);

            //true by default
            Assert.That(session.PersistMessages);

            settings.SetBool(SessionSettings.PERSIST_MESSAGES, false);
            session = factory.Create(sessionID, settings);

            Assert.That(!session.PersistMessages);
        }
Beispiel #25
0
        private void LoadXml()
        {
            xmlDoc = new XmlDocument();
            xmlDoc.Load("Scenarios.xml");

            XDocument xDoc = XDocument.Load("Scenarios.xml");

            // QFN Default Session Settings
            //defaults = new Dictionary();
            //IEnumerable<XElement> xDefault = xDoc.Root.Element("QFNSessionSettings").Element("Default").Descendants();
            //foreach (XElement xe in xDefault)
            //{
            //    defaults.SetString(xe.Name.ToString(), xe.Value);
            //}

            // QFN Specific Session Settings
            session = new Dictionary();
            IEnumerable <XElement> xSession = xDoc.Root.Element("QFNSessionSettings").Element("Session").Descendants();

            foreach (XElement xe in xSession)
            {
                session.SetString(xe.Name.ToString(), xe.Value);
            }

            SessionID sessionID = new SessionID(session.GetString("BeginString"), session.GetString("SenderCompID"), session.GetString("TargetCompID"));

            ConfigurationSingleton.Instance.RemovaAllQFNSettings();
            //ConfigurationSingleton.Instance.AddQFNSettings(defaults);
            ConfigurationSingleton.Instance.AddQFNSettings(sessionID, session);
            ConfigurationSingleton.Instance.SetTagsToIgnore(xDoc.Root.Element("TagsToIgnore").Value);

            sc      = new List <string>();
            scNodes = new List <XmlNode>();
            foreach (XmlNode xNode in xmlDoc.GetElementsByTagName("Scenario"))
            {
                sc.Add(xNode.Attributes["Name"].Value);
                scNodes.Add(xNode);
            }
        }
        public void TestExtendedSettings()
        {
            IApplication app = new NullApplication();
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionFactory factory = new SessionFactory(app, storeFactory);

            SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET");
            Dictionary settings = new Dictionary();
            settings.SetString(SessionSettings.USE_DATA_DICTIONARY, "N");
            settings.SetString(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS, "Y");
            settings.SetString(SessionSettings.RESEND_SESSION_LEVEL_REJECTS, "Y");
            settings.SetString(SessionSettings.MILLISECONDS_IN_TIMESTAMP, "Y");
            settings.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            settings.SetString(SessionSettings.HEARTBTINT, "30");
            settings.SetString(SessionSettings.START_TIME, "12:00:00");
            settings.SetString(SessionSettings.END_TIME, "12:00:00");
            settings.SetString(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED, "Y");
            settings.SetString(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST, "2500");
            settings.SetString(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT, "Y");
            settings.SetString(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS, "Y");

            Session session = factory.Create(sessionID, settings);

            Assert.That(session.SendRedundantResendRequests);
            Assert.That(session.ResendSessionLevelRejects);
            Assert.That(session.MillisecondsInTimeStamp);

            settings.SetString(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS, "N");
            settings.SetString(SessionSettings.RESEND_SESSION_LEVEL_REJECTS, "N");
            settings.SetString(SessionSettings.MILLISECONDS_IN_TIMESTAMP, "N");
            session = factory.Create(sessionID, settings);

            Assert.That(!session.SendRedundantResendRequests);
            Assert.That(!session.ResendSessionLevelRejects);
            Assert.That(!session.MillisecondsInTimeStamp);
            Assert.That(session.EnableLastMsgSeqNumProcessed);
            Assert.That(session.MaxMessagesInResendRequest, Is.EqualTo(2500));
            Assert.That(session.SendLogoutBeforeTimeoutDisconnect);
            Assert.That(session.IgnorePossDupResendRequests);
        }
Beispiel #27
0
        public ChannelTcpConflated(TCPConflatedConfig conflatedConfig)
        {
            logger = LogManager.GetLogger("ChannelTcpConflated-" + conflatedConfig.ChannelID);

            MDSUtils.AddAppender("ChannelTcpConflated-" + conflatedConfig.ChannelID, logger.Logger);

            _bKeepRunning = true;

            machineGun = new MachineGunFixSplitter();
            machineGun.UnderFIXMessageFire += new FIXMachineGunEventHandler(machineGun_UnderFIXMessageFire);
            machineGun.Start();

            thQueueProc = new Thread(new ThreadStart(queueProc));
            thQueueProc.Start();

            thSplitProc = new Thread(new ThreadStart(splitterThreadWork));
            thSplitProc.Start();

            _channelUmdfConfig = conflatedConfig;

            //if (!listaChannelQueues.ContainsKey(conflatedConfig.ChannelID))
            //    listaChannelQueues.Add(conflatedConfig.ChannelID, new ListChannelQueues(qUdpPkt, replayLockObject));

            logger.Info("Start(): iniciando sessao FIX...");
            try
            {
                // Cria sessao FIX
                _session = new QuickFix.SessionID(
                    conflatedConfig.BeginString,
                    conflatedConfig.SenderCompID,
                    conflatedConfig.TargetCompID);

                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetLong("SocketConnectPort", conflatedConfig.ProxyPort);
                mainDic.SetLong("HeartBtInt", conflatedConfig.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", conflatedConfig.ReconnectInterval);
                mainDic.SetBool("ResetOnLogon", conflatedConfig.ResetOnLogon);
                mainDic.SetBool("ResetOnLogout", conflatedConfig.ResetOnLogout);
                mainDic.SetBool("ResetOnDisconnect", conflatedConfig.ResetOnDisconnect);
                mainDic.SetBool("PersistMessages", conflatedConfig.PersistMessages);
                mainDic.SetString("ConnectionType", conflatedConfig.ConnectionType);
                mainDic.SetString("SocketConnectHost", conflatedConfig.ProxyHost);
                mainDic.SetString("FileStorePath", conflatedConfig.FileStorePath);
                mainDic.SetString("FileLogPath", conflatedConfig.FileLogPath);
                mainDic.SetString("StartTime", conflatedConfig.StartTime);
                mainDic.SetString("EndTime", conflatedConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", conflatedConfig.BeginString);
                sessDic.SetString("SenderCompID", conflatedConfig.SenderCompID);

                sessDic.SetString("TargetCompID", conflatedConfig.TargetCompID);
                sessDic.SetString("DataDictionary", conflatedConfig.DataDictionary);
                sessDic.SetBool("CheckLatency", false);
                sessDic.SetBool("UseDataDictionary", true);
                sessDic.SetLong("SocketReceiveBufferSize", conflatedConfig.SocketReceiveBufferSize);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);
                settings.Set(_session, sessDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                // Cria o socket
                _initiator = new QuickFix.Transport.SocketInitiator(this, store, settings, this, message);
                _initiator.Start();

                QuickFix.Session mySession = QuickFix.Session.LookupSession(_session);
                QuickFix.Session.LookupSession(_session).ValidateLengthAndChecksum = false;
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciado!");
        }
Beispiel #28
0
        public FixInitiator(MarketIncrementalProcessor mktIncProc, ChannelUMDFConfig channelUmdfConfig, string templateFile, Queue <UdpPacket> qUdpPkt, Object replayLockObject)
        {
            logger = LogManager.GetLogger("FixInitiator-" + channelUmdfConfig.ChannelID);

            MDSUtils.AddAppender("FixInitiator-" + channelUmdfConfig.ChannelID, logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(templateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            _mktIncProc        = mktIncProc;
            _channelUmdfConfig = channelUmdfConfig;

            if (!listaChannelQueues.ContainsKey(channelUmdfConfig.ChannelID))
            {
                listaChannelQueues.Add(channelUmdfConfig.ChannelID, new ListChannelQueues(qUdpPkt, replayLockObject));
            }

            logger.Info("Start(): iniciando sessao FIX...");
            try
            {
                // Cria sessao FIX
                _session = new QuickFix.SessionID(
                    _channelUmdfConfig.TCPConfig.BeginString,
                    _channelUmdfConfig.TCPReplayConfig.SenderCompID,
                    _channelUmdfConfig.TCPReplayConfig.SubID,
                    _channelUmdfConfig.TCPReplayConfig.TargetCompID,
                    _channelUmdfConfig.TCPReplayConfig.SubID);

                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetLong("SocketConnectPort", _channelUmdfConfig.TCPReplayConfig.SocketConnectPort);
                mainDic.SetLong("HeartBtInt", _channelUmdfConfig.TCPConfig.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", _channelUmdfConfig.TCPConfig.ReconnectInterval);
                mainDic.SetBool("ResetOnLogon", _channelUmdfConfig.TCPConfig.ResetOnLogon);
                mainDic.SetBool("ResetOnLogout", _channelUmdfConfig.TCPConfig.ResetOnLogout);
                mainDic.SetBool("ResetOnDisconnect", _channelUmdfConfig.TCPConfig.ResetOnDisconnect);
                mainDic.SetBool("PersistMessages", _channelUmdfConfig.TCPConfig.PersistMessages);
                mainDic.SetString("ConnectionType", _channelUmdfConfig.TCPConfig.ConnectionType);
                mainDic.SetString("SocketConnectHost", _channelUmdfConfig.TCPReplayConfig.SocketConnectHost);
                mainDic.SetString("FileStorePath", _channelUmdfConfig.TCPConfig.FileStorePath);
                mainDic.SetString("FileLogPath", _channelUmdfConfig.TCPConfig.FileLogPath);
                mainDic.SetString("StartTime", _channelUmdfConfig.TCPReplayConfig.StartTime);
                mainDic.SetString("EndTime", _channelUmdfConfig.TCPReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", _channelUmdfConfig.TCPConfig.BeginString);
                sessDic.SetString("SenderCompID", _channelUmdfConfig.TCPReplayConfig.SenderCompID);
                sessDic.SetString("SenderSubID", _channelUmdfConfig.TCPReplayConfig.SubID);
                sessDic.SetString("TargetCompID", _channelUmdfConfig.TCPReplayConfig.TargetCompID);
                sessDic.SetString("TargetSubID", _channelUmdfConfig.TCPReplayConfig.SubID);
                sessDic.SetString("DataDictionary", _channelUmdfConfig.TCPConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);
                settings.Set(_session, sessDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                // Cria o socket
                _initiator = new QuickFix.Transport.SocketInitiator(this, store, settings, log, message);
                _initiator.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciado!");
        }
Beispiel #29
0
        public FixServerAcceptor(
            TCPReplayConfig tcpReplayConfig,
            Dictionary <string, SessionID> dctSessionsFixClients,
            Dictionary <string, SessionID> dctSessionsFixChannels)
        {
            _tcpReplayConfig        = tcpReplayConfig;
            _dctSessionsFixClients  = dctSessionsFixClients;
            _dctSessionsFixChannels = dctSessionsFixChannels;

            logger = LogManager.GetLogger("FixServerAcceptor");

            MDSUtils.AddAppender("FixServerAcceptor", logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(tcpReplayConfig.TemplateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            try
            {
                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetLong("SocketAcceptPort", tcpReplayConfig.SocketAcceptPort);
                mainDic.SetBool("ResetOnLogon", tcpReplayConfig.ResetOnLogon);
                mainDic.SetBool("ResetOnDisconnect", tcpReplayConfig.ResetOnDisconnect);
                mainDic.SetBool("PersistMessages", tcpReplayConfig.PersistMessages);
                mainDic.SetString("ConnectionType", tcpReplayConfig.ConnectionType);
                mainDic.SetString("FileStorePath", tcpReplayConfig.FileStorePath);
                mainDic.SetString("FileLogPath", tcpReplayConfig.FileLogPath);
                mainDic.SetString("StartTime", tcpReplayConfig.StartTime);
                mainDic.SetString("EndTime", tcpReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", tcpReplayConfig.BeginString);
                sessDic.SetString("SenderCompID", tcpReplayConfig.SenderCompID);
                sessDic.SetString("TargetCompID", tcpReplayConfig.TargetCompID);
                sessDic.SetString("DataDictionary", tcpReplayConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                IEnumerable <int> rangeSenderSubID = Enumerable.Range(
                    tcpReplayConfig.SubIDStartSeq,
                    tcpReplayConfig.SubIDEndSeq);
                foreach (int item in rangeSenderSubID)
                {
                    string subID = tcpReplayConfig.SubIDPrefix + item.ToString("D3");

                    // Cria sessao FIX
                    SessionID sessionID = new QuickFix.SessionID(
                        tcpReplayConfig.BeginString,
                        tcpReplayConfig.SenderCompID,
                        subID,
                        tcpReplayConfig.TargetCompID,
                        subID);

                    sessDic.SetString("SenderSubID", subID);
                    sessDic.SetString("TargetSubID", subID);
                    settings.Set(sessionID, sessDic);
                }

                logger.InfoFormat("Start(): iniciando FIX ACCEPTOR na porta {0}...", tcpReplayConfig.SocketAcceptPort);
                _acceptor = new ThreadedSocketAcceptor(this, store, settings, log, message);
                _acceptor.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciada!");
        }
        void StartEngine(bool initiator)
        {
            TestApplication application = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            SessionSettings settings = new SessionSettings();
            Dictionary defaults = new Dictionary();
            defaults.SetString(QuickFix.SessionSettings.FILE_LOG_PATH, LogPath);

            // Put IP endpoint settings into default section to verify that that defaults get merged into
            // session-specific settings not only for static sessions, but also for dynamic ones
            defaults.SetString(SessionSettings.SOCKET_CONNECT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_CONNECT_PORT, ConnectPort.ToString());
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_HOST, Host);
            defaults.SetString(SessionSettings.SOCKET_ACCEPT_PORT, AcceptPort.ToString());

            settings.Set(defaults);
            ILogFactory logFactory = new FileLogFactory(settings);

            if (initiator)
            {
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
Beispiel #31
0
        public void ValueEquality()
        {
            QuickFix.Dictionary first = new QuickFix.Dictionary("Name");
            QuickFix.Dictionary second = new QuickFix.Dictionary("Name");
            Assert.True(first.Equals(second));

            first.SetString("THIRDKEY", "FIRST");
            second.SetString("THIRDKEY", "SECOND");
            Assert.False(first.Equals(second));

            first.SetString("THIRDKEY", "SECOND");
            Assert.True(first.Equals(second));

            first.SetString("FIRSTKEY", "FIRSTVALUE");
            second.SetString("SECONDKEY", "SECONDVALUE");
            Assert.False(first.Equals(second));

            first.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("FIRSTKEY", "FIRSTVALUE");
            Assert.True(first.Equals(second));

            QuickFix.Dictionary third = new QuickFix.Dictionary("Name1");
            QuickFix.Dictionary fourth = new QuickFix.Dictionary("Name2");
            Assert.False(third.Equals(fourth));
        }
Beispiel #32
0
        void StartEngine(bool initiator)
        {
            TestApplication application = new TestApplication(LogonCallback, LogoffCallback);
            IMessageStoreFactory storeFactory = new MemoryStoreFactory();
            ILogFactory logFactory = new ScreenLogFactory(false, false, false);
            SessionSettings settings = new SessionSettings();

            if (initiator)
            {
                Dictionary defaults = new Dictionary();
                defaults.SetString(SessionSettings.RECONNECT_INTERVAL, "1");
                settings.Set(defaults);
                settings.Set(CreateSessionID(StaticInitiatorCompID), CreateSessionConfig(StaticInitiatorCompID, true));
                _initiator = new SocketInitiator(application, storeFactory, settings, logFactory);
                _initiator.Start();
            }
            else
            {
                settings.Set(CreateSessionID(StaticAcceptorCompID), CreateSessionConfig(StaticAcceptorCompID, false));
                _acceptor = new ThreadedSocketAcceptor(application, storeFactory, settings, logFactory);
                _acceptor.Start();
            }
        }
Beispiel #33
0
        public void ThreadSafeSetAndGet()
        {
            //Set up store
            if (System.IO.Directory.Exists("store")) {
                System.IO.Directory.Delete("store", true);
            }

            SessionID sessionId = new SessionID("FIX.4.2", "SENDERCOMP", "TARGETCOMP");

            Dictionary config = new Dictionary();
            config.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            config.SetString(SessionSettings.FILE_STORE_PATH, "store");

            SessionSettings settings = new SessionSettings();
            settings.Set(sessionId, config);
            FileStoreFactory factory = new FileStoreFactory(settings);

            FileStore store = (FileStore)factory.Create(sessionId);

            NullLog log = new NullLog();

            //Set up sessionstate
            SessionState state = new SessionState(log, 1) {MessageStore = store};

            Hashtable errorsTable = Hashtable.Synchronized(new Hashtable());//used in more than 1 thread at a time
            Hashtable setTable = new Hashtable(1000);//only used in 1 thread at a time
            Hashtable getTable = new Hashtable(1000);//only used in 1 thread at a time

            //Synchronously populate 1000 messages
            for (int i = 1; i < 1000; i++) {
                string msg = "msg" + i;
                state.Set(i, msg);
                setTable[i] = msg;
            }

            //Simulate background sending of messages that populate into the store
            AutoResetEvent setEvent = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate(object stateObject) {
                AutoResetEvent internalSetEvent = (AutoResetEvent)((object[])stateObject)[0];
                SessionState internalState = (SessionState)((object[])stateObject)[1];
                for (int i = 1001; i < 2000; i++) {
                    try {
                        internalState.Set(i, "msg" + i);
                    }
                    catch (System.IO.IOException ex) {
                        errorsTable[ex.Message] = ex;
                    }
                }

                internalSetEvent.Set();
            }
            , new object[] { setEvent, state });

            //Simulate background reading of messages from the store - like is done in a resend request answer
            AutoResetEvent getEvent = new AutoResetEvent(false);
            ThreadPool.QueueUserWorkItem(delegate(object stateObject){
                AutoResetEvent internalGetEvent = (AutoResetEvent)((object[])stateObject)[0];
                SessionState internalState = (SessionState)((object[])stateObject)[1];
                for (int i = 1; i < 1000; i++) {
                    try {
                        List<string> lst = new List<string>(1);
                        internalState.Get(i, i, lst);
                        if (lst.Count == 0) {
                            getTable[i] = "nothing read";
                        }
                        else {
                            getTable[i] = lst[0];
                        }
                    }
                    catch (System.IO.IOException ex) {
                        errorsTable[ex.Message] = ex;
                    }
                }

                internalGetEvent.Set();
            }
            , new object[]{getEvent, state});

            //wait till done and assert results
            Assert.True(setEvent.WaitOne(10000), "Get or Set hung/timed out during concurrent usage");
            Assert.True(getEvent.WaitOne(10000), "Get or Set hung/timed out during concurrent usage");
            Assert.AreEqual(setTable, getTable, "Garbled data read  in concurrent set and get (like between resendrequest and send)");
            Assert.AreEqual(errorsTable.Count, 0, "IOException occured in concurrent set and get (like between resendrequest and send)");

            //Tear down filestore
            state.Dispose();
            store.Dispose();
        }
Beispiel #34
0
        public void Validate()
        {
            SessionSettings settings = new SessionSettings();
            SessionID sessionID = new SessionID("FIX.4.2", "SenderCompID", "TargetCompID");

            // ConnectionType not set
            QuickFix.Dictionary dictionary = new QuickFix.Dictionary();
            Assert.Throws<ConfigError>(delegate { settings.Set(sessionID, dictionary); });

            // ConnectionType set to invalid value
            dictionary.SetString(SessionSettings.CONNECTION_TYPE, "badvalue");
            Assert.Throws<ConfigError>(delegate { settings.Set(sessionID, dictionary); });

            // ConnectionType set to valid value
            dictionary.SetString(SessionSettings.CONNECTION_TYPE, "initiator");
            Assert.DoesNotThrow(delegate { settings.Set(sessionID, dictionary); });

            // Invalid BeginString
            sessionID = new SessionID("FIX4.2", "SenderCompID", "TargetCompID");
            Assert.Throws<ConfigError>(delegate { settings.Set(sessionID, dictionary); });
        }
Beispiel #35
0
        public FixServerInitiator(
            string channelsID,
            TCPReplayConfig tcpReplayConfig,
            Dictionary <string, SessionID> dctSessionsFixClients,
            Dictionary <string, SessionID> dctSessionsFixChannels)
        {
            _tcpReplayConfig        = tcpReplayConfig;
            _dctSessionsFixClients  = dctSessionsFixClients;
            _dctSessionsFixChannels = dctSessionsFixChannels;

            logger = LogManager.GetLogger("FixServerInitiator-" + tcpReplayConfig.ChannelID);

            MDSUtils.AddAppender("FixServerInitiator-" + tcpReplayConfig.ChannelID, logger.Logger);

            XMLMessageTemplateLoader loader = new XMLMessageTemplateLoader();

            registry = UmdfUtils.loadTemplates(tcpReplayConfig.TemplateFile);
            context  = new Context();
            context.TemplateRegistry = registry;

            try
            {
                // Cria dicionario da configuracao
                QuickFix.Dictionary mainDic = new QuickFix.Dictionary();
                mainDic.SetString("SocketConnectHost", tcpReplayConfig.SocketConnectHost);
                mainDic.SetLong("SocketConnectPort", tcpReplayConfig.SocketConnectPort);
                if (!String.IsNullOrEmpty(tcpReplayConfig.SocketConnectHost1))
                {
                    mainDic.SetString("SocketConnectHost1", tcpReplayConfig.SocketConnectHost1);
                    mainDic.SetLong("SocketConnectPort1", tcpReplayConfig.SocketConnectPort1);
                }
                mainDic.SetLong("HeartBtInt", tcpReplayConfig.HeartBtInt);
                mainDic.SetLong("ReconnectInterval", tcpReplayConfig.ReconnectInterval);
                mainDic.SetBool("ResetOnLogon", tcpReplayConfig.ResetOnLogon);
                mainDic.SetBool("PersistMessages", tcpReplayConfig.PersistMessages);
                mainDic.SetString("ConnectionType", tcpReplayConfig.ConnectionType);
                mainDic.SetString("FileStorePath", tcpReplayConfig.FileStorePath);
                mainDic.SetString("FileLogPath", tcpReplayConfig.FileLogPath);
                mainDic.SetString("StartTime", tcpReplayConfig.StartTime);
                mainDic.SetString("EndTime", tcpReplayConfig.EndTime);

                QuickFix.Dictionary sessDic = new QuickFix.Dictionary();
                sessDic.SetString("BeginString", tcpReplayConfig.BeginString);
                sessDic.SetString("SenderCompID", tcpReplayConfig.SenderCompID);
                sessDic.SetString("TargetCompID", tcpReplayConfig.TargetCompID);
                sessDic.SetString("DataDictionary", tcpReplayConfig.DataDictionary);
                sessDic.SetBool("UseDataDictionary", true);

                // Configure the session settings
                QuickFix.SessionSettings settings = new QuickFix.SessionSettings();

                settings.Set(mainDic);

                MemoryStoreFactory store   = new MemoryStoreFactory();
                FileLogFactory     log     = new FileLogFactory(settings);
                IMessageFactory    message = new DefaultMessageFactory();

                // Cria sessao FIX
                _sessionID = new QuickFix.SessionID(
                    tcpReplayConfig.BeginString,
                    tcpReplayConfig.SenderCompID,
                    tcpReplayConfig.TargetCompID);

                settings.Set(_sessionID, sessDic);

                string[] quebraChannelsID = channelsID.Split(",".ToCharArray());
                foreach (string channel in quebraChannelsID)
                {
                    dctSessionsFixChannels.Add(channel, _sessionID);
                }

                logger.InfoFormat("Start(): iniciando FIX com sessionID[{0}]...", _sessionID.ToString());
                _initiator = new QuickFix.Transport.SocketInitiator(this, store, settings, log, message);
                _initiator.Start();
            }
            catch (Exception ex)
            {
                logger.Error("Start():" + ex.Message, ex);
            }

            logger.Info("Start(): Sessao FIX iniciada!");
        }