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); } }
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 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 SetDouble() { // 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.SetDouble("DOUBLEKEY1", 12.3); d.SetDouble("DOUBLEKEY2", 987362.987362); Assert.AreEqual("12.3", d.GetString("DOUBLEKEY1")); Assert.AreEqual("987362.987362", d.GetString("DOUBLEKEY2")); }