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 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)); }
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)); }