Identifies a session. Only supports a company ID (target, sender) and a session qualifier. Sessions are also identified by FIX version so that it's possible to have multiple sessions to the same counterparty but using different FIX versions (and/or session qualifiers).
コード例 #1
1
ファイル: Server.cs プロジェクト: huruixd/quickfixn
 private void OnMessage(QuickFix.FIX42.MarketDataRequest m, SessionID s)
 {
     QuickFix.FIX42.MarketDataRequest.NoRelatedSymGroup symbolGroup = new QuickFix.FIX42.MarketDataRequest.NoRelatedSymGroup();
     m.GetGroup(1, symbolGroup);
     string symbolName = symbolGroup.Get(new Symbol()).getValue();
     string mdRequestId = m.MDReqID.ToString();
     if (!m_ProductSubscription.ContainsKey(symbolName)) {
         bool fullSpeed = symbolName.StartsWith("B");
         Console.WriteLine("Subscribe : " + symbolName + ". Full Speed: " + fullSpeed);
         QuotePublisher publisher = new QuotePublisher(symbolName, mdRequestId, fullSpeed, s);
         m_ProductSubscription.Add(symbolName, publisher);
     }
 }
コード例 #2
0
ファイル: QuickFIX43Application.cs プロジェクト: heber/FreeOQ
		public virtual void onLogon(SessionID sessionID)
		{
			Console.WriteLine("SessionID: " + sessionID);
			if (this.IxROVD6JN == null)
				return;
			this.IxROVD6JN((object)this, new FIXSessionIDEventArgs(sessionID));
		}
コード例 #3
0
        internal static dynamic OrderCancelRequest(SessionID sid)
        {
            if (sid == null)
            {
                return null;
            }

            string value = sid.getBeginString();

            if (value.Equals("FIX.4.0"))
                return new QuickFix40.OrderCancelRequest();

            if (value.Equals("FIX.4.1"))
                return new QuickFix41.OrderCancelRequest();

            if (value.Equals("FIX.4.2"))
                return new QuickFix42.OrderCancelRequest();

            if (value.Equals("FIX.4.3"))
                return new QuickFix43.OrderCancelRequest();

            if (value.Equals("FIX.4.4"))
                return new QuickFix44.OrderCancelRequest();

            if (value.Equals("FIX.5.0"))
                return new QuickFix50.OrderCancelRequest();

            return null;
        }
コード例 #4
0
ファイル: QuickeFixApp.cs プロジェクト: OKCoin/fix
        public void OnLogon( SessionID sessionID)
        {
            Session session = Session.LookupSession(sessionID);
            Message message =  null;

            //行情订阅
            message = OKMarketDataRequest.create24HTickerRequest();

            //深度订阅
            //message = OKMarketDataRequest.createOrderBookRequest();

            //用户信息请求
            //message = OKTradingRequest.createUserAccountRequest();

            //创建订单
            // try{
            //     message = OKTradingRequest.createOrderBookRequest();
            // } catch (Exception e) {
            //     Console.WriteLine(e.Message);
            // }

             //取消订单请求
             // message = OKTradingRequest.createOrderCancelRequest();

             //订单状态请求
             // message = OKTradingRequest.createOrderStatusRequest();
            session.Send(message);
        }
コード例 #5
0
        internal static dynamic NewOrderSingle(SessionID sid)
        {
            if (sid == null)
            {
                return null;
            }

            string value = sid.getBeginString();

            if (value.Equals("FIX.4.0"))
                return new QuickFix40.NewOrderSingle();

            if (value.Equals("FIX.4.1"))
                return new QuickFix41.NewOrderSingle();

            if (value.Equals("FIX.4.2"))
                return new QuickFix42.NewOrderSingle();

            if (value.Equals("FIX.4.3"))
                return new QuickFix43.NewOrderSingle();

            if (value.Equals("FIX.4.4"))
                return new QuickFix44.NewOrderSingle();

            if (value.Equals("FIX.5.0"))
                return new QuickFix50.NewOrderSingle();

            return null;
        }
コード例 #6
0
ファイル: QuickFIX42Application.cs プロジェクト: heber/FreeOQ
		public virtual void onLogon(SessionID sessionID)
		{
			Console.WriteLine("SessionID: " + sessionID);
			if (this.lCISky2Q1 == null)
				return;
			this.lCISky2Q1(this, new FIXSessionIDEventArgs(sessionID));
		}
コード例 #7
0
ファイル: QuickFIX42Application.cs プロジェクト: heber/FreeOQ
		public virtual void onLogout(SessionID sessionID)
		{
			Console.WriteLine("SessionID: " + sessionID);
			if (this.N4PQenDmP == null)
				return;
			this.N4PQenDmP(this, new FIXSessionIDEventArgs(sessionID));
		}
コード例 #8
0
        public void SendNewOrderSingle(string symbol, int quantity, decimal? price, decimal? stop, decimal? gain, string account, SessionID session)
        {
            clOrdId = DateTime.Now.Ticks.ToString();
            lastSymbol = symbol;
            lastAccount = account;

            var newOrderSingle = new NewOrderSingle(new ClOrdID(clOrdId),
                                                    new Symbol(symbol),
                                                    new Side(Side.BUY),
                                                    new TransactTime(DateTime.Now),
                                                    new OrdType(gain.HasValue ? 'X' : stop.HasValue ? OrdType.STOP : price.HasValue ? OrdType.LIMIT : OrdType.MARKET))
                {
                    Account = new Account(account),
                    OrderQty = new OrderQty(quantity),
                    TargetStrategy = new TargetStrategy(TargetStrategy),
                    TimeInForce = new TimeInForce(TIF),
                };

            if (TIF == TimeInForce.GOOD_TILL_DATE)
                newOrderSingle.ExpireDate = new ExpireDate(DateTime.Today.AddDays(1).AsLocalMktDate());

            if (stop.HasValue)
                newOrderSingle.StopPx = new StopPx(stop.Value);

            if (price.HasValue)
                newOrderSingle.Price = new Price(price.Value);

            if (gain.HasValue)
                newOrderSingle.SetField(new DecimalField(6001, gain.Value));

            Session.SendToTarget(newOrderSingle, session);
        }
コード例 #9
0
		public override void onLogout(SessionID sessionID)
		{
			bool flag1;
			if (this.priceSessionID == null)
			{
				flag1 = true;
			}
			else
			{
				Session session = Session.lookupSession(this.priceSessionID);
				flag1 = session != null && !session.isLoggedOn();
			}
			bool flag2;
			if (this.orderSessionID == null)
			{
				flag2 = true;
			}
			else
			{
				Session session = Session.lookupSession(this.orderSessionID);
				flag2 = session != null && !session.isLoggedOn();
			}
			if (!flag1 || !flag2)
				return;
			this.EmitLogout((SessionID)null);
		}
コード例 #10
0
ファイル: QuickFIX43Application.cs プロジェクト: heber/FreeOQ
		public virtual void onLogout(SessionID sessionID)
		{
			Console.WriteLine("SessionID: " + sessionID);
			if (this.Br2Z76TG6 == null)
				return;
			this.Br2Z76TG6((object)this, new FIXSessionIDEventArgs(sessionID));
		}
コード例 #11
0
ファイル: ServerQuickFix.cs プロジェクト: bluejack2000/core
        public void fromApp(QuickFix.Message message, SessionID sessionID)
        {
            // receiving messages
            Symbol sym = new Symbol();
            message.getField(sym);
            Tick k = new TickImpl(sym.getValue());
			
			{
            // bid
            BidPx bp = new BidPx();
            BidSize bs = new BidSize();
            k.bid = (decimal)bp.getValue();
            k.bs = (int)message.getField(bs).getValue();
			}
			
			{
            // ask
            OfferPx op = new OfferPx();
            OfferSize os = new OfferSize();
            k.ask = (decimal)op.getValue();
            k.os = (int)message.getField(os).getValue();
			}
			
			{
            // last
            Price price = new Price();
            message.getField(price);
            k.trade = (decimal)price.getValue();
			}
			
            tl.newTick(k);
            //ClOrdID clOrdID = new ClOrdID();
            //message.getField(clOrdID);
        }
コード例 #12
0
ファイル: FileStore.cs プロジェクト: blackhill/quickfixn
        public FileStore(string path, SessionID sessionID)
        {
            //BEGIN - Custom part

            //search for special directory (ie: %appdata%)
            if (path.StartsWith("%"))
            {
                int end = path.IndexOf("%", 1);
                string specialFolderName = path.Substring(1, end - 1);

                Environment.SpecialFolder specialFolder = (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), specialFolderName, true);
                string specialPath = Environment.GetFolderPath(specialFolder);

                path = Path.Combine(specialPath, path.Substring(end + 2));
            }

            //END - Custom part

            if (!System.IO.Directory.Exists(path))
                System.IO.Directory.CreateDirectory(path);

            string prefix = Prefix(sessionID);

            seqNumsFileName_ = System.IO.Path.Combine(path, prefix + ".seqnums");
            msgFileName_ = System.IO.Path.Combine(path, prefix + ".body");
            headerFileName_ = System.IO.Path.Combine(path, prefix + ".header");
            sessionFileName_ = System.IO.Path.Combine(path, prefix + ".session");

            open();
        }
コード例 #13
0
ファイル: FIXApplication.cs プロジェクト: benofben/implier
        public void onLogon(SessionID sessionID)
        {
            Console.WriteLine("onLogon " + sessionID);

            String exchange = "CME";
            String symbol = "CL";
            RequestSymbols(exchange, symbol, sessionID);
        }
コード例 #14
0
ファイル: ATApplication.cs プロジェクト: Paccc/quickfixn
        public void OnCreate(SessionID sessionID)
        {
            Session session = Session.LookupSession(sessionID);

            // Hey QF/J users, don't do this in a real app.
            if (null != session)
                session.Reset("AT Session Reset");
        }
コード例 #15
0
 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"));
     }
 }
コード例 #16
0
ファイル: Session.cs プロジェクト: huruixd/quickfixn
        public Session(
            IApplication app, IMessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, ILogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SenderDefaultApplVerID = senderDefaultApplVerID;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            ILog log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt)
            {
                MessageStore = storeFactory.Create(sessID)
            };

            // Configuration defaults.
            // Will be overridden by the SessionFactory with values in the user's configuration.
            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;
            this.MillisecondsInTimeStamp = true;
            this.EnableLastMsgSeqNumProcessed = false;
            this.MaxMessagesInResendRequest = 0;
            this.SendLogoutBeforeTimeoutDisconnect = false;
            this.IgnorePossDupResendRequests = false;
            this.RequiresOrigSendingTime = true;
            this.CheckLatency = true;
            this.MaxLatency = 120;

            if (!IsSessionTime)
                Reset("Out of SessionTime (Session construction)");
            else if (IsNewSession)
                Reset("New session");

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
コード例 #17
0
        public void OnMessage(QuickFix.FIX44.NewOrderSingle n, SessionID s)
        {
            Console.WriteLine("* Got a NewOrderSingle.  Responding with an ExecutionReport.");

            Symbol symbol = n.Symbol;
            Side side = n.Side;
            OrdType ordType = n.OrdType;
            OrderQty orderQty = n.OrderQty;
            Price price = new Price(DEFAULT_MARKET_PRICE);
            ClOrdID clOrdID = n.ClOrdID;

            switch (ordType.getValue())
            {
                case OrdType.LIMIT:
                    price = n.Price;
                    if (price.Obj == 0)
                        throw new IncorrectTagValue(price.Tag);
                    break;
                case OrdType.MARKET: break;
                default: throw new IncorrectTagValue(ordType.Tag);
            }

            QuickFix.FIX44.ExecutionReport exReport = new QuickFix.FIX44.ExecutionReport(
                new OrderID(GenOrderID()),
                new ExecID(GenExecID()),
                new ExecType(ExecType.FILL),
                new OrdStatus(OrdStatus.FILLED),
                symbol, //shouldn't be here?
                side,
                new LeavesQty(0),
                new CumQty(orderQty.getValue()),
                new AvgPx(price.getValue()));

            exReport.Set(clOrdID);
            exReport.Set(symbol);
            exReport.Set(orderQty);
            exReport.Set(new LastQty(orderQty.getValue()));
            exReport.Set(new LastPx(price.getValue()));

            if (n.IsSetAccount())
                exReport.SetField(n.Account);

            try
            {
                Session.SendToTarget(exReport, s);
            }
            catch (SessionNotFound ex)
            {
                Console.WriteLine("==session not found exception!==");
                Console.WriteLine(ex.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
コード例 #18
0
ファイル: FIXApplication.cs プロジェクト: benofben/implier
 public void fromAdmin(Message message, SessionID sessionID)
 {
     if (!isTimerAdjusted)
     {
         SendingTime sendingTime = new SendingTime();
         message.getHeader().getField(sendingTime);
         Utils.AdjustTime(sendingTime.getValue());
         isTimerAdjusted = true;
     }
 }
コード例 #19
0
        public void Crack(Message message, SessionID sessionID)
        {
            Type messageType = message.GetType();
            MethodInfo handler = null;

            if (_handlerMethods.TryGetValue(messageType, out handler))
                handler.Invoke(this, new object[] { message, sessionID });
            else
                throw new UnsupportedMessageType();
        }
コード例 #20
0
 public void OnMessage(QuickFix.FIX44.News msg, SessionID sessionId)
 {
     //byte[] ole = Encoding.UTF8.GetBytes("olé");
     QuickFix.FIX44.News response = new QuickFix.FIX44.News();
     response.Header.SetField(new QuickFix.Fields.MessageEncoding("UTF-8"));
     response.Headline = new QuickFix.Fields.Headline("ole");
     response.EncodedHeadline = new QuickFix.Fields.EncodedHeadline("olé");
     response.LinesOfText = new QuickFix.Fields.LinesOfText(0);
     Session.SendToTarget(response, sessionId);
 }
コード例 #21
0
ファイル: Client.cs プロジェクト: huruixd/quickfixn
 public void FromApp(Message message, SessionID sessionID)
 {
     OnMessage(message, sessionID);
     string msgType = message.Header.GetString(Tags.MsgType);
     switch (msgType) {
         case "8":
             OnExecutionReport((QuickFix.FIX42.ExecutionReport)message);
             break;
     }
 }
コード例 #22
0
 public void EnqueueAddOrder(IFixMessageGenerator messageGenerator,
                             SessionID sessionID,
                             OrderData orderData,
                             string execID)
 {
     var internalSessionID = _sessionMediator.LookupInternalSessionID(sessionID);
     var cmd = _commandFactory.CreateAddOrder(messageGenerator,
                                              internalSessionID,
                                              orderData,
                                              execID);
     _commandFactory.IncomingQueue.Enqueue(cmd);
 }
コード例 #23
0
ファイル: Server.cs プロジェクト: huruixd/quickfixn
 public void FromApp(Message message, SessionID sessionID)
 {
     string msgType = message.Header.GetString(Tags.MsgType);
     switch (msgType) {
         case "V":
             OnMessage(((QuickFix.FIX42.MarketDataRequest)message), sessionID);
             break;
         case "D":
             OnMessage(((QuickFix.FIX42.NewOrderSingle)message), sessionID);
             break;
     }
 }
コード例 #24
0
ファイル: SessionIDTest.cs プロジェクト: RemiGaudin/quickfixn
 public void TestAllFieldsConstructor()
 {
     SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "SENDERSUB", "SENDERLOC", "TARGET", "TARGETSUB", "TARGETLOC", "QUALIFIER");
     Assert.That(sessionID.BeginString, Is.EqualTo("FIX.4.2"));
     Assert.That(sessionID.SenderCompID, Is.EqualTo("SENDER"));
     Assert.That(sessionID.SenderSubID, Is.EqualTo("SENDERSUB"));
     Assert.That(sessionID.SenderLocationID, Is.EqualTo("SENDERLOC"));
     Assert.That(sessionID.TargetCompID, Is.EqualTo("TARGET"));
     Assert.That(sessionID.TargetSubID, Is.EqualTo("TARGETSUB"));
     Assert.That(sessionID.TargetLocationID, Is.EqualTo("TARGETLOC"));
     Assert.That(sessionID.SessionQualifier, Is.EqualTo("QUALIFIER"));
 }
コード例 #25
0
ファイル: FIXApplication.cs プロジェクト: benofben/implier
 public void fromApp(Message message, SessionID sessionID)
 {
     try
     {
         crack(message, sessionID);
     }
     catch (UnsupportedMessageType exception)
     {
         Console.WriteLine("fromApp " + exception);
         Console.WriteLine("fromApp " + message);
     }
 }
コード例 #26
0
ファイル: SessionIDTest.cs プロジェクト: RemiGaudin/quickfixn
 public void TestNoLocationSubOrQualifierConstructor()
 {
     SessionID sessionID = new SessionID("FIX.4.2", "SENDER", "TARGET");
     Assert.That(sessionID.BeginString, Is.EqualTo("FIX.4.2"));
     Assert.That(sessionID.SenderCompID, Is.EqualTo("SENDER"));
     Assert.That(sessionID.SenderSubID, Is.EqualTo(""));
     Assert.That(sessionID.SenderLocationID, Is.EqualTo(""));
     Assert.That(sessionID.TargetCompID, Is.EqualTo("TARGET"));
     Assert.That(sessionID.TargetSubID, Is.EqualTo(""));
     Assert.That(sessionID.TargetLocationID, Is.EqualTo(""));
     Assert.That(sessionID.SessionQualifier, Is.EqualTo(""));
 }
コード例 #27
0
ファイル: FileStore.cs プロジェクト: atesio/quickfixn
        public FileStore(string path, SessionID sessionID)
        {
            if (!System.IO.Directory.Exists(path))
                System.IO.Directory.CreateDirectory(path);

            string prefix = Prefix(sessionID);

            seqNumsFileName_ = System.IO.Path.Combine(path, prefix + ".seqnums");
            msgFileName_ = System.IO.Path.Combine(path, prefix + ".body");
            headerFileName_ = System.IO.Path.Combine(path, prefix + ".header");

            open();
        }
コード例 #28
0
ファイル: Session.cs プロジェクト: FascetTest/quickfixn
        /// FIXME
        public Session(
            Application app, MessageStoreFactory storeFactory, SessionID sessID, DataDictionaryProvider dataDictProvider,
            SessionSchedule sessionSchedule, int heartBtInt, LogFactory logFactory, IMessageFactory msgFactory, string senderDefaultApplVerID)
        {
            this.Application = app;
            this.SessionID = sessID;
            this.DataDictionaryProvider = new DataDictionaryProvider(dataDictProvider);
            this.schedule_ = sessionSchedule;
            this.msgFactory_ = msgFactory;

            this.SenderDefaultApplVerID = senderDefaultApplVerID;

            this.SessionDataDictionary = this.DataDictionaryProvider.GetSessionDataDictionary(this.SessionID.BeginString);
            if (this.SessionID.IsFIXT)
                this.ApplicationDataDictionary = this.DataDictionaryProvider.GetApplicationDataDictionary(this.SenderDefaultApplVerID);
            else
                this.ApplicationDataDictionary = this.SessionDataDictionary;

            Log log;
            if (null != logFactory)
                log = logFactory.Create(sessID);
            else
                log = new NullLog();

            state_ = new SessionState(log, heartBtInt)
            {
                MessageStore = storeFactory.Create(sessID)
            };

            this.PersistMessages = true;
            this.ResetOnDisconnect = false;
            this.SendRedundantResendRequests = false;
            this.ValidateLengthAndChecksum = true;
            this.CheckCompID = true;
            this.MillisecondsInTimeStamp = true;
            this.EnableLastMsgSeqNumProcessed = false;
            this.MaxMessagesInResendRequest = 0;
            this.SendLogoutBeforeTimeoutDisconnect = false;
            this.IgnorePossDupResendRequests = false;

            if (!IsSessionTime)
                Reset();

            lock (sessions_)
            {
                sessions_[this.SessionID] = this;
            }

            this.Application.OnCreate(this.SessionID);
            this.Log.OnEvent("Created session");
        }
コード例 #29
0
 public void FromApp(QuickFix.Message msg, SessionID sessionID)
 {
     Console.WriteLine("FromApp - " + msg.ToString() + "@" + sessionID.ToString());
     try
     {
         Crack(msg, sessionID);
     }
     catch (Exception ex)
     {
         Console.WriteLine("==Cracker exception==");
         Console.WriteLine(ex.ToString());
         Console.WriteLine(ex.StackTrace);
     }
 }
コード例 #30
0
ファイル: Program.cs プロジェクト: qualityking/javacommon
        public void fromApp(QuickFix.Message value, SessionID session)
        {
            //if (value is QuickFix42.ExecutionReport)
            //{
            //    QuickFix42.ExecutionReport er = (QuickFix42.ExecutionReport)value;
            //    ExecType et = (ExecType)er.getExecType();
            //    if (et.getValue() == ExecType.FILL)
            //    {
            //        //TODO: implement code
            //    }
            //}

            //Console.WriteLine("Got Execution Report from Server \n" + value.ToString());
        }
コード例 #31
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());
        }
コード例 #32
0
ファイル: ChannelTcpConflated.cs プロジェクト: radtek/Gradual
        public virtual void ToApp(QuickFix.Message message, QuickFix.SessionID session)
        {
            try
            {
                if (logger.IsDebugEnabled)
                {
                    logger.Debug("SND(App) --> type[" + message.GetType().ToString() + "] msg[" + message.ToString() + "]");
                }

                //this.Crack(message, session);
            }
            catch (Exception ex)
            {
                logger.Error("ToApp(): " + ex.Message, ex);
            }
        }
コード例 #33
0
        public void ToAdmin(QuickFix.Message message, QuickFix.SessionID session)
        {
            // Faz o processamento
            try
            {
                // Complementa a mensagem de logon com a senha
                if (message.GetType() == typeof(Logon))
                {
                    Logon message2 = (Logon)message;
                    if (_config.LogonPassword != "")
                    {
                        message2.Set(new RawData(_config.LogonPassword));
                        message2.Set(new RawDataLength(_config.LogonPassword.Length));
                        if (_config.NewPassword != null && _config.NewPassword.Length > 0)
                        {
                            // message2.setString(925, _config.NewPassword.Trim());
                            NewPassword newpwd = new NewPassword(_config.NewPassword.Trim());
                            message2.SetField(newpwd);
                        }
                    }

                    if (_config.CancelOnDisconnect >= 0)
                    {
                        char codtype = _config.CancelOnDisconnect.ToString()[0];
                        if (codtype >= '0' && codtype <= '3')
                        {
                            message2.SetField(new CharField(35002, codtype));
                        }
                        if (_config.CODTimeout >= 0 && _config.CODTimeout <= 60)
                        {
                            message2.SetField(new IntField(35003, _config.CODTimeout * 1000));
                        }
                    }
                    message2.Set(new HeartBtInt(_config.HeartBtInt));
                    message2.Set(new EncryptMethod(0));
                    message2.Set(new ResetSeqNumFlag(_config.ResetSeqNum));
                }
                if (message.Header.GetField(Tags.MsgType) != MsgType.HEARTBEAT)
                {
                    this.Crack(message, session);
                }
            }
            catch (Exception ex)
            {
                logger.Error("toAdmin() Erro: " + ex.Message, ex);
            }
        }
コード例 #34
0
        public virtual void toAdmin(QuickFix.Message message, QuickFix.SessionID session)
        {
            // Faz o processamento
            try
            {
                logger.Debug("toAdmin(). Session id : " + session.ToString() + " Msg: " + message.GetType().ToString());

                if (message.getHeader().getField(MsgType.FIELD) != QuickFix.MsgType.Heartbeat)
                {
                    this.crack(message, session);
                }
            }
            catch (Exception ex)
            {
                logger.Error("toAdmin() Erro: " + ex.Message, ex);
            }
        }
コード例 #35
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message">Market data snapshot full refresh message</param>
        /// <param name="session">Session ID</param>
        private void OnMessage(QuickFix.FIX43.MarketDataSnapshotFullRefresh message, QuickFix.SessionID session)
        {
            try
            {
                int numberOfMarketDataEntries = message.NoMDEntries.getValue();

                for (int i = 1; i <= numberOfMarketDataEntries; i++)
                {
                    Tick tick = new Tick(new Security()
                    {
                        Symbol = message.Symbol.getValue()
                    }, _provider);

                    tick.DateTime = message.Header.GetDateTime(QuickFix.Fields.Tags.SendingTime);
                    QuickFix.Group group = message.GetGroup(i, QuickFix.Fields.Tags.NoMDEntries);
                    if (group.GetField(QuickFix.Fields.Tags.MDEntryType).Equals("0"))
                    {
                        tick.BidPrice    = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntryPx));
                        tick.BidSize     = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntrySize));
                        tick.BidExchange = group.GetField(QuickFix.Fields.Tags.MDEntryOriginator);
                    }
                    if (group.GetField(QuickFix.Fields.Tags.MDEntryType).Equals("1"))
                    {
                        tick.AskPrice    = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntryPx));
                        tick.AskSize     = Convert.ToDecimal(group.GetField(QuickFix.Fields.Tags.MDEntrySize));
                        tick.AskExchange = group.GetField(QuickFix.Fields.Tags.MDEntryOriginator);
                    }

                    if (TickArrived != null)
                    {
                        TickArrived(tick);
                    }
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString(), _type.FullName, "OnMessage");
            }
        }
コード例 #36
0
ファイル: ChannelTcpConflated.cs プロジェクト: radtek/Gradual
        public virtual void ToAdmin(QuickFix.Message message, QuickFix.SessionID session)
        {
            try
            {
                logger.Debug("SND(Admin) --> type[" + message.GetType().ToString() + "] msg[" + message.ToString() + "]");
                //if (message.Header.GetField(QuickFix.Fields.Tags.MsgType) != QuickFix.Fields.MsgType.HEARTBEAT)
                //    this.Crack(message, session);
                // Complementa a mensagem de logon com a senha
                if (message.GetType() == typeof(Logon))
                {
                    Logon message2 = (Logon)message;
                    if (_channelUmdfConfig.LogonPassword != "")
                    {
                        message2.Set(new QuickFix.Fields.RawData(_channelUmdfConfig.LogonPassword));
                        message2.Set(new QuickFix.Fields.RawDataLength(_channelUmdfConfig.LogonPassword.Length));
                        if (_channelUmdfConfig.NewPassword != null && _channelUmdfConfig.NewPassword.Length > 0)
                        {
                            QuickFix.Fields.StringField newPassword = new QuickFix.Fields.StringField(925, _channelUmdfConfig.NewPassword.Trim());
                            message2.SetField(newPassword);
                        }
                    }

                    message2.Set(new QuickFix.Fields.HeartBtInt(_channelUmdfConfig.HeartBtInt));
                    message2.Set(new QuickFix.Fields.EncryptMethod(0));
                    message2.Set(new QuickFix.Fields.ResetSeqNumFlag(_channelUmdfConfig.ResetOnLogon));
                }

                logger.Debug("ToAdmin(). Session id : " + session.ToString() + " Msg: " + message.GetType().ToString());

                //if (message.getHeader().getField(MsgType.FIELD) != QuickFix.MsgType.Heartbeat)
                //    this.crack(message, session);
            }
            catch (Exception ex)
            {
                logger.Error("ToAdmin(): " + ex.Message, ex);
            }
        }
コード例 #37
0
ファイル: ChannelTcpConflated.cs プロジェクト: radtek/Gradual
        public virtual void Stop()
        {
            try
            {
                _bKeepRunning = false;

                _initiator.Stop();
                _initiator = null;
                _session   = null;

                while (thSplitProc.IsAlive)
                {
                    logger.Info("Aguardando finalizar thread splitter");
                    Thread.Sleep(250);
                }

                while (thQueueProc.IsAlive)
                {
                    logger.Info("Aguardando finalizar thread de processamento da fila de mensagens FIX");
                    Thread.Sleep(250);
                }

                if (machineGun != null)
                {
                    machineGun.Stop();
                }
            }
            catch (Exception ex)
            {
                logger.Error("Stop():" + ex.Message, ex);
            }

            _logonEfetuado = false;

            logger.Info("Stop(): Sessao FIX finalizado!");
        }
コード例 #38
0
 public void toApp(QuickFix.Message value, QuickFix.SessionID session)
 {
     //  Console.WriteLine("Called toApp :" + value.ToString());
 }
コード例 #39
0
        private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(SessionSettings settings, SessionID sessionID)
        {
            QuickFix.Dictionary dict      = settings.Get(sessionID);
            int            port           = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT));
            SocketSettings socketSettings = new SocketSettings();

            IPEndPoint socketEndPoint;

            if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST))
            {
                string      host  = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST);
                IPAddress[] addrs = Dns.GetHostAddresses(host);
                socketEndPoint = new IPEndPoint(addrs[0], port);
                // Set hostname (if it is not already configured)
                socketSettings.ServerCommonName = socketSettings.ServerCommonName ?? host;
            }
            else
            {
                socketEndPoint = new IPEndPoint(IPAddress.Any, port);
            }

            socketSettings.Configure(dict);


            AcceptorSocketDescriptor descriptor;

            if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor))
            {
                descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict);
                socketDescriptorForAddress_[socketEndPoint] = descriptor;
            }

            return(descriptor);
        }
コード例 #40
0
 public void onLogout(QuickFix.SessionID value)
 {
     SystemLogger.WriteOnConsoleAsync(true, "Client Logged Out" + value.ToString(), ConsoleColor.Red, ConsoleColor.White, false);
     // Console.WriteLine("Log out Session" + value.toString());
 }
コード例 #41
0
 public void toAdmin(QuickFix.Message value, QuickFix.SessionID session)
 {
     //SystemLogger.WriteOnConsoleAsync(true, "To Admin: " + value.ToString(), ConsoleColor.Black, ConsoleColor.White, false);
 }
コード例 #42
0
        public override void onMessage(QuickFix42.ExecutionReport report, QuickFix.SessionID sessionID)
        {
            if (report.getExecType().getValue() == QuickFix.ExecType.PENDING_CANCEL ||
                report.getExecType().getValue() == QuickFix.ExecType.CANCELED ||
                report.getExecType().getValue() == QuickFix.ExecType.PENDING_REPLACE ||
                report.getExecType().getValue() == QuickFix.ExecType.REPLACE)
            {
                object request = cancelRequests[report.getClOrdID().getValue()];

                if (request == null)
                {
                    report.set(new OrigClOrdID(report.getClOrdID().getValue()));
                }
                else
                {
                    if (request is FIXOrderCancelRequest)
                    {
                        report.set(new OrigClOrdID((request as FIXOrderCancelRequest).OrigClOrdID));
                    }

                    if (request is FIXOrderCancelReplaceRequest)
                    {
                        report.set(new OrigClOrdID((request as FIXOrderCancelReplaceRequest).OrigClOrdID));
                    }
                }
            }

            ExecutionReport Report = new ExecutionReport();

            if (report.isSetOrderID())
            {
                Report.OrderID = report.getOrderID().getValue();
            }
            ////if (report.isSetSecondaryOrderID()) Report.SecondaryOrderID = report.getSecondaryOrderID().getValue();
            if (report.isSetClOrdID())
            {
                Report.ClOrdID = report.getClOrdID().getValue();
            }
            if (report.isSetOrigClOrdID())
            {
                Report.OrigClOrdID = report.getOrigClOrdID().getValue();
            }
            ////if (report.isSetListID()) Report.ListID = report.getListID().getValue();
            if (report.isSetExecID())
            {
                Report.ExecID = report.getExecID().getValue();
            }
            ////if (report.isSetExecRefID()) Report.ExecRefID = report.getExecRefID().getValue();
            if (report.isSetExecType())
            {
                (Report as FIXExecutionReport).ExecType = report.getExecType().getValue();
            }
            if (report.isSetOrdStatus())
            {
                (Report as FIXExecutionReport).OrdStatus = report.getOrdStatus().getValue();
            }
            if (report.isSetOrdRejReason())
            {
                Report.OrdRejReason = report.getOrdRejReason().getValue();
            }
            ////if (report.isSetExecRestatementReason()) Report.ExecRestatementReason = report.getExecRestatementReason().getValue();
            ////if (report.isSetAccount()) Report.Account = report.getAccount().getValue();
            ////if (report.isSetSettlmntTyp()) Report.SettlType = report.getSettlmntTyp().getValue();
            //if (report.isSetFutSettDate           ()) Report.FutSettDate            = report.getFutSettDate           ().getValue();
            if (report.isSetSymbol())
            {
                Report.Symbol = report.getSymbol().getValue();
            }
            ////if (report.isSetSymbolSfx()) Report.SymbolSfx = report.getSymbolSfx().getValue();
            ////if (report.isSetSecurityID()) Report.SecurityID = report.getSecurityID().getValue();
            //if (report.isSetIDSource              ()) Report.IDSource               = report.getIDSource              ().getValue();
            ////if (report.isSetSecurityType()) Report.SecurityType = report.getSecurityType().getValue();
            ////if (report.isSetMaturityMonthYear()) Report.MaturityMonthYear = report.getMaturityMonthYear().getValue();
            //if (report.isSetMaturityDay           ()) Report.MaturityDate           = DateTime.Parse(report.getMaturityDay           ().getValue());
            //if (report.isSetPutOrCall             ()) Report.PutOrCall              = report.getPutOrCall             ().getValue();
            ////if (report.isSetStrikePrice()) Report.StrikePrice = report.getStrikePrice().getValue();
            ////if (report.isSetOptAttribute()) Report.OptAttribute = report.getOptAttribute().getValue();
            ////if (report.isSetContractMultiplier()) Report.ContractMultiplier = report.getContractMultiplier().getValue();
            ////if (report.isSetCouponRate()) Report.CouponRate = report.getCouponRate().getValue();
            ////if (report.isSetSecurityExchange()) Report.SecurityExchange = report.getSecurityExchange().getValue();
            ////if (report.isSetIssuer()) Report.Issuer = report.getIssuer().getValue();
            ////if (report.isSetEncodedIssuerLen()) Report.EncodedIssuerLen = report.getEncodedIssuerLen().getValue();
            ////if (report.isSetEncodedIssuer()) Report.EncodedIssuer = report.getEncodedIssuer().getValue();
            ////if (report.isSetSecurityDesc()) Report.SecurityDesc = report.getSecurityDesc().getValue();
            ////if (report.isSetEncodedSecurityDescLen()) Report.EncodedSecurityDescLen = report.getEncodedSecurityDescLen().getValue();
            ////if (report.isSetEncodedSecurityDesc()) Report.EncodedSecurityDesc = report.getEncodedSecurityDesc().getValue();
            if (report.isSetSide())
            {
                (Report as FIXExecutionReport).Side = report.getSide().getValue();
            }
            if (report.isSetOrderQty())
            {
                Report.OrderQty = report.getOrderQty().getValue();
            }
            ////if (report.isSetCashOrderQty()) Report.CashOrderQty = report.getCashOrderQty().getValue();
            if (report.isSetOrdType())
            {
                (Report as FIXExecutionReport).OrdType = report.getOrdType().getValue();
            }
            if (report.isSetPrice())
            {
                Report.Price = report.getPrice().getValue();
            }
            ////if (report.isSetStopPx()) Report.StopPx = report.getStopPx().getValue();
            //if (report.isSetPegDifference         ()) Report.PegDifference          = report.getPegDifference         ().getValue();
            ////if (report.isSetDiscretionInst()) Report.DiscretionInst = report.getDiscretionInst().getValue();
            ////if (report.isSetDiscretionOffset()) Report.DiscretionOffsetValue = report.getDiscretionOffset().getValue();
            ////if (report.isSetCurrency()) Report.Currency = report.getCurrency().getValue();
            ////if (report.isSetComplianceID()) Report.ComplianceID = report.getComplianceID().getValue();
            //if (report.isSetSolicitedFlag         ()) Report.SolicitedFlag          = report.getSolicitedFlag         ().getValue();
            ////if (report.isSetTimeInForce()) (Report as FIXExecutionReport).TimeInForce = report.getTimeInForce().getValue();
            ////if (report.isSetEffectiveTime()) Report.EffectiveTime = report.getEffectiveTime().getValue();
            ////if (report.isSetExpireDate()) Report.ExpireDate = DateTime.Parse(report.getExpireDate().getValue());
            ////if (report.isSetExpireTime()) Report.ExpireTime = report.getExpireTime().getValue();
            ////if (report.isSetExecInst()) Report.ExecInst = report.getExecInst().getValue();
            //if (report.isSetRule80A               ()) Report.Rule80A                = report.getRule80A               ().getValue();
            if (report.isSetLastShares())
            {
                Report.LastQty = report.getLastShares().getValue();
            }
            if (report.isSetLastPx())
            {
                Report.LastPx = report.getLastPx().getValue();
            }
            ////if (report.isSetLastSpotRate()) Report.LastSpotRate = report.getLastSpotRate().getValue();
            ////if (report.isSetLastForwardPoints()) Report.LastForwardPoints = report.getLastForwardPoints().getValue();
            ////if (report.isSetLastMkt()) Report.LastMkt = report.getLastMkt().getValue();
            ////if (report.isSetTradingSessionID()) Report.TradingSessionID = report.getTradingSessionID().getValue();
            ////if (report.isSetLastCapacity()) Report.LastCapacity = report.getLastCapacity().getValue();
            if (report.isSetLeavesQty())
            {
                Report.LeavesQty = report.getLeavesQty().getValue();
            }
            if (report.isSetCumQty())
            {
                Report.CumQty = report.getCumQty().getValue();
            }
            if (report.isSetAvgPx())
            {
                Report.AvgPx = report.getAvgPx().getValue();
            }
            ////if (report.isSetDayOrderQty()) Report.DayOrderQty = report.getDayOrderQty().getValue();
            ////if (report.isSetDayCumQty()) Report.DayCumQty = report.getDayCumQty().getValue();
            ////if (report.isSetDayAvgPx()) Report.DayAvgPx = report.getDayAvgPx().getValue();
            ////if (report.isSetGTBookingInst()) Report.GTBookingInst = report.getGTBookingInst().getValue();
            ////if (report.isSetTradeDate()) Report.TradeDate = DateTime.Parse(report.getTradeDate().getValue());
            if (report.isSetTransactTime())
            {
                Report.TransactTime = report.getTransactTime().getValue();
            }
            //if (report.isSetReportToExch          ()) Report.ReportToExch           = report.getReportToExch          ().getValue();
            ////if (report.isSetCommission()) Report.Commission = report.getCommission().getValue();
            ////if (report.isSetCommType()) (Report as FIXExecutionReport).CommType = report.getCommType().getValue();
            ////if (report.isSetGrossTradeAmt()) Report.GrossTradeAmt = report.getGrossTradeAmt().getValue();
            ////if (report.isSetSettlCurrAmt()) Report.SettlCurrAmt = report.getSettlCurrAmt().getValue();
            ////if (report.isSetSettlCurrency()) Report.SettlCurrency = report.getSettlCurrency().getValue();
            ////if (report.isSetHandlInst()) Report.HandlInst = report.getHandlInst().getValue();
            ////if (report.isSetMinQty()) Report.MinQty = report.getMinQty().getValue();
            ////if (report.isSetMaxFloor()) Report.MaxFloor = report.getMaxFloor().getValue();
            //if (report.isSetOpenClose             ()) Report.OpenClose              = report.getOpenClose             ().getValue();
            ////if (report.isSetMaxShow()) Report.MaxShow = report.getMaxShow().getValue();
            if (report.isSetText())
            {
                Report.Text = report.getText().getValue();
            }
            ////if (report.isSetEncodedTextLen()) Report.EncodedTextLen = report.getEncodedTextLen().getValue();
            ////if (report.isSetEncodedText()) Report.EncodedText = report.getEncodedText().getValue();
            //if (report.isSetFutSettDate2          ()) Report.FutSettDate2           = report.getFutSettDate2          ().getValue();
            ////if (report.isSetOrderQty2()) Report.OrderQty2 = report.getOrderQty2().getValue();
            //if (report.isSetClearingFirm          ()) Report.ClearingFirm           = report.getClearingFirm          ().getValue();
            //if (report.isSetClearingAccount       ()) Report.ClearingAccount        = report.getClearingAccount       ().getValue();
            ////if (report.isSetMultiLegReportingType()) Report.MultiLegReportingType = report.getMultiLegReportingType().getValue();

            //

            SingleOrder order;

            if (Report.ExecType == SmartQuant.FIX.ExecType.PendingCancel ||
                Report.ExecType == SmartQuant.FIX.ExecType.Cancelled ||
                Report.ExecType == SmartQuant.FIX.ExecType.PendingReplace ||
                Report.ExecType == SmartQuant.FIX.ExecType.Replace)
            {
                order = OrderManager.Orders.All[Report.OrigClOrdID] as SingleOrder;
            }
            else
            {
                order = OrderManager.Orders.All[Report.ClOrdID] as SingleOrder;
            }

            Instrument instrument = order.Instrument;

            Report.Symbol = instrument.Symbol;

            Report.TransactTime = Clock.Now;

            // emit execution report

            EmitExecutionReport(Report);
        }
コード例 #43
0
 public void onCreate(QuickFix.SessionID value)
 {
     //Console.WriteLine("Message OnCreate" + value.toString());
 }
コード例 #44
0
ファイル: ServidorFix.cs プロジェクト: radtek/Gradual
        public void IniciarServico()
        {
            logger.Info("IniciarServico(): iniciando Servidor FIX...");

            // Carrega configurações
            _config = GerenciadorConfig.ReceberConfig <ServidorFixConfig>();

            // Cria dicionario da configuracao
            Dictionary mainDic = new Dictionary();

            if (_config.SocketAcceptPort > 0)
            {
                mainDic.SetLong("SocketAcceptPort", _config.SocketAcceptPort);
            }
            //mainDic.SetLong("SocketConnectPort", _config.SocketConnectPort);
            mainDic.SetLong("HeartBtInt", _config.HeartBtInt);
            mainDic.SetLong("ReconnectInterval", _config.ReconnectInterval);

            //mainDic.SetBool("ResetOnLogon", _config.ResetSeqNum);
            //mainDic.SetBool("PersistMessages", _config.PersistMessages);

            // Ver
            // ret.setString("ConnectionType", ConnectionType.ToLower());
            //mainDic.SetString("SocketConnectHost", _config.Host);
            mainDic.SetString("FileStorePath", _config.FileStorePath);

            logger.Debug("FileLogPath: " + _config.FileLogPath);
            mainDic.SetString("FileLogPath", _config.FileLogPath);

            logger.Debug("DebugFileLogPath: " + _config.FileLogPath);
            mainDic.SetString("DebugFileLogPath", _config.DebugFileLogPath);
            mainDic.SetString("StartTime", _config.StartTime);
            mainDic.SetString("EndTime", _config.EndTime);
            mainDic.SetString("ConnectionType", "acceptor");

            CamadaDeDados         db       = new CamadaDeDados();
            List <SessionFixInfo> sessions = db.BuscarSessoesFIX();

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

            settings.Set(mainDic);


            foreach (SessionFixInfo info in sessions)
            {
                Dictionary sessDic = new Dictionary();

                //sessDic.SetString("BeginString", _config.BeginString);
                //sessDic.SetString("SenderCompID", _config.SenderCompID);
                //sessDic.SetString("TargetCompID", _config.TargetCompID);

                string dataDictionary;

                switch (info.FixVersion)
                {
                case "5.0": dataDictionary = _config.DataDictionary50; break;

                case "4.4": dataDictionary = _config.DataDictionary44; break;

                case "4.2":
                default:
                    dataDictionary = _config.DataDictionary42; break;
                }

                sessDic.SetString("DataDictionary", dataDictionary);
                sessDic.SetBool("UseDataDictionary", true);
                sessDic.SetBool("ResetOnLogon", info.ResetSeqNum != 0?true:false);
                sessDic.SetBool("PersistMessages", info.PersistMessages != 0 ? true : false);

                logger.InfoFormat("Criando sessao S:[{0}] T:[{1}] Ver:[{2}] Dic:[{3}] Rst:[{4}] Pers:[{5}] Begstr:[{6}]",
                                  info.SenderCompID,
                                  info.TargetCompID,
                                  info.FixVersion,
                                  dataDictionary,
                                  info.ResetSeqNum,
                                  info.PersistMessages,
                                  info.BeginString
                                  );

                // Cria sessao que será usada para mandar as mensagens
                _session =
                    new SessionID(info.BeginString,
                                  info.SenderCompID,
                                  info.TargetCompID);

                settings.Set(_session, sessDic);
            }

            logger.Info("Iniciando gerenciador de limites...");
            LimiteManager.GetInstance().Start();

            logger.Info("Iniciando cron scheduler...");
            _cron = new CronStyleScheduler();
            _cron.Start();

            logger.Info("Iniciando Executor FIX...");
            _executorApp = Executor.GetInstance();
            _executorApp.Start();

            FileStoreFactory store = new FileStoreFactory(settings);

            LogFactory      logs = new FileLogFactory(settings);
            IMessageFactory msgs = new DefaultMessageFactory();

            logger.Info("Iniciando ThreadedSocketAcceptor...");
            _socketAcceptor = new ThreadedSocketAcceptor(_executorApp, store, settings, logs, msgs);
            _socketAcceptor.Start();

            _status = ServicoStatus.EmExecucao;

            logger.Info("IniciarServico(): ServidorFIX em execucao....");
        }
コード例 #45
0
ファイル: SessionFactory.cs プロジェクト: Breslov/FIXity
 protected void ProcessFixDataDictionary(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
 {
     DataDictionary.DataDictionary dataDictionary = createDataDictionary(sessionID, settings, SessionSettings.DATA_DICTIONARY, sessionID.BeginString);
     provider.AddTransportDataDictionary(sessionID.BeginString, dataDictionary);
     provider.AddApplicationDataDictionary(FixValues.ApplVerID.FromBeginString(sessionID.BeginString), dataDictionary);
 }
コード例 #46
0
        public override void onMessage(QuickFix42.MarketDataSnapshotFullRefresh snapshot, QuickFix.SessionID sessionID)
        {
            if (snapshot.isSetNoMDEntries())
            {
                string reqID = snapshot.getMDReqID().getValue();

                Instrument instrument = (provider as GSFIX).GetInstrument(reqID);

                instrument.OrderBook.Clear();

                QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries group = new QuickFix42.MarketDataSnapshotFullRefresh.NoMDEntries();

                Quote quote = new Quote();

                quote.DateTime = Clock.Now;

                for (uint i = 1; i <= snapshot.getNoMDEntries().getValue(); i++)
                {
                    snapshot.getGroup(i, group);

                    SmartQuant.Data.MarketDepth depth;

                    int position = 0;

                    if (group.isSetMDEntryPositionNo())
                    {
                        position = group.getMDEntryPositionNo().getValue() - 1;
                    }

                    double price = group.getMDEntryPx().getValue();
                    int    size  = (int)group.getMDEntrySize().getValue();

                    // Console.WriteLine("Snapshot Level : " + position + " " + price + " " + size);

                    switch (group.getMDEntryType().getValue())
                    {
                    case QuickFix.MDEntryType.TRADE:

                        provider.EmitTrade(new Trade(Clock.Now, price, size), instrument);

                        break;

                    case QuickFix.MDEntryType.BID:

                        // market depth

                        depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Insert, MDSide.Bid, price, size);

                        provider.EmitMarketDepth(depth, instrument);

                        // quote

                        if (position == 0)
                        {
                            quote.Bid     = price;
                            quote.BidSize = size;
                        }

                        break;

                    case QuickFix.MDEntryType.OFFER:

                        // market depth

                        depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Insert, MDSide.Ask, price, size);

                        provider.EmitMarketDepth(depth, instrument);

                        // quote

                        if (position == 0)
                        {
                            quote.Ask     = price;
                            quote.AskSize = size;
                        }

                        break;
                    }
                }

                group.Dispose();

                provider.EmitQuote(quote, instrument);
            }
        }
コード例 #47
0
 /// <summary>
 /// Creates a composite log
 /// </summary>
 /// <param name="sessionID">session ID for the message store</param>
 /// <returns></returns>
 public ILog Create(SessionID sessionID)
 {
     return(new CompositeLog(factories_.Select(f => f.Create(sessionID)).ToArray()));
 }
コード例 #48
0
ファイル: FixInitiator.cs プロジェクト: radtek/Gradual
 public virtual void OnLogon(QuickFix.SessionID session)
 {
     logger.Info("OnLogon()");
     _bConectadoBolsa = true;
 }
コード例 #49
0
 /// <summary>
 /// Implemented to connect a session to its target.
 /// </summary>
 /// <param name="sessionID"></param>
 /// <param name="settings"></param>
 protected abstract void DoConnect(SessionID sessionID, QuickFix.Dictionary settings);
コード例 #50
0
ファイル: FixServerInitiator.cs プロジェクト: radtek/Gradual
 public virtual void OnLogout(QuickFix.SessionID session)
 {
     logger.Info("OnLogout()");
 }
コード例 #51
0
ファイル: SessionSettings.cs プロジェクト: zobad16/quickfixn
 /// <summary>
 /// Remove existing session config from the settings
 /// </summary>
 /// <param name="sessionID">ID of session for which config is to be removed</param>
 /// <returns>true if removed, false if config for the session does not exist</returns>
 public bool Remove(SessionID sessionID)
 {
     return(settings_.Remove(sessionID));
 }
コード例 #52
0
ファイル: SessionFactory.cs プロジェクト: Breslov/FIXity
        public Session Create(SessionID sessionID, QuickFix.Dictionary settings)
        {
            string connectionType = settings.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"acceptor".Equals(connectionType) && !"initiator".Equals(connectionType))
            {
                throw new ConfigError("Invalid ConnectionType");
            }

            if ("acceptor".Equals(connectionType) && settings.Has(SessionSettings.SESSION_QUALIFIER))
            {
                throw new ConfigError("SessionQualifier cannot be used with acceptor.");
            }

            bool useDataDictionary = true;

            if (settings.Has(SessionSettings.USE_DATA_DICTIONARY))
            {
                useDataDictionary = settings.GetBool(SessionSettings.USE_DATA_DICTIONARY);
            }

            QuickFix.Fields.ApplVerID defaultApplVerID = null;
            if (sessionID.IsFIXT)
            {
                if (!settings.Has(SessionSettings.DEFAULT_APPLVERID))
                {
                    throw new ConfigError("ApplVerID is required for FIXT transport");
                }
                defaultApplVerID = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
            }

            DataDictionaryProvider dd = new DataDictionaryProvider();

            if (useDataDictionary)
            {
                if (sessionID.IsFIXT)
                {
                    ProcessFixTDataDictionaries(sessionID, settings, dd);
                }
                else
                {
                    ProcessFixDataDictionary(sessionID, settings, dd);
                }
            }

            int heartBtInt = 0;

            if (connectionType == "initiator")
            {
                heartBtInt = System.Convert.ToInt32(settings.GetLong(SessionSettings.HEARTBTINT));
                if (heartBtInt <= 0)
                {
                    throw new ConfigError("Heartbeat must be greater than zero");
                }
            }
            string senderDefaultApplVerId = "";

            if (defaultApplVerID != null)
            {
                senderDefaultApplVerId = defaultApplVerID.Obj;
            }

            Session session = new Session(
                application_,
                messageStoreFactory_,
                sessionID,
                dd,
                new SessionSchedule(settings),
                heartBtInt,
                logFactory_,
                messageFactory_,
                senderDefaultApplVerId);

            if (settings.Has(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS))
            {
                session.SendRedundantResendRequests = settings.GetBool(SessionSettings.SEND_REDUNDANT_RESENDREQUESTS);
            }

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.CHECK_COMPID))
             *  session.SetCheckCompId(settings.GetBool(SessionSettings.CHECK_COMPID));
             */
            if (settings.Has(SessionSettings.CHECK_LATENCY))
            {
                session.CheckLatency = settings.GetBool(SessionSettings.CHECK_LATENCY);
            }
            if (settings.Has(SessionSettings.MAX_LATENCY))
            {
                session.MaxLatency = settings.GetInt(SessionSettings.MAX_LATENCY);
            }
            if (settings.Has(SessionSettings.LOGON_TIMEOUT))
            {
                session.LogonTimeout = settings.GetInt(SessionSettings.LOGON_TIMEOUT);
            }
            if (settings.Has(SessionSettings.LOGOUT_TIMEOUT))
            {
                session.LogoutTimeout = settings.GetInt(SessionSettings.LOGOUT_TIMEOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGON))
            {
                session.ResetOnLogon = settings.GetBool(SessionSettings.RESET_ON_LOGON);
            }
            if (settings.Has(SessionSettings.RESET_ON_LOGOUT))
            {
                session.ResetOnLogout = settings.GetBool(SessionSettings.RESET_ON_LOGOUT);
            }
            if (settings.Has(SessionSettings.RESET_ON_DISCONNECT))
            {
                session.ResetOnDisconnect = settings.GetBool(SessionSettings.RESET_ON_DISCONNECT);
            }
            if (settings.Has(SessionSettings.REFRESH_ON_LOGON))
            {
                session.RefreshOnLogon = settings.GetBool(SessionSettings.REFRESH_ON_LOGON);
            }
            if (settings.Has(SessionSettings.PERSIST_MESSAGES))
            {
                session.PersistMessages = settings.GetBool(SessionSettings.PERSIST_MESSAGES);
            }
            if (settings.Has(SessionSettings.MILLISECONDS_IN_TIMESTAMP))
            {
                session.MillisecondsInTimeStamp = settings.GetBool(SessionSettings.MILLISECONDS_IN_TIMESTAMP);
            }
            if (settings.Has(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED))
            {
                session.EnableLastMsgSeqNumProcessed = settings.GetBool(SessionSettings.ENABLE_LAST_MSG_SEQ_NUM_PROCESSED);
            }
            if (settings.Has(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST))
            {
                session.MaxMessagesInResendRequest = settings.GetInt(SessionSettings.MAX_MESSAGES_IN_RESEND_REQUEST);
            }
            if (settings.Has(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT))
            {
                session.SendLogoutBeforeTimeoutDisconnect = settings.GetBool(SessionSettings.SEND_LOGOUT_BEFORE_TIMEOUT_DISCONNECT);
            }
            if (settings.Has(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS))
            {
                session.IgnorePossDupResendRequests = settings.GetBool(SessionSettings.IGNORE_POSSDUP_RESEND_REQUESTS);
            }

            /** FIXME - implement optional settings
             * if (settings.Has(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM))
             *  session.SetValidateLengthAndChecksum(settings.GetBool(SessionSettings.VALIDATE_LENGTH_AND_CHECKSUM));
             */
            if (settings.Has(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME))
            {
                session.RequiresOrigSendingTime = settings.GetBool(SessionSettings.RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME);
            }

            return(session);
        }
コード例 #53
0
ファイル: SessionSettings.cs プロジェクト: zobad16/quickfixn
 public bool Has(SessionID sessionID)
 {
     return(settings_.ContainsKey(sessionID));
 }
コード例 #54
0
ファイル: FixServerAcceptor.cs プロジェクト: radtek/Gradual
        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!");
        }
コード例 #55
0
 public ILog Create(SessionID sessionID)
 {
     return(new ODBCLog(settings_, sessionID));
 }
コード例 #56
0
        public override void onMessage(QuickFix42.MarketDataIncrementalRefresh refresh, QuickFix.SessionID sessionID)
        {
            if (refresh.isSetNoMDEntries())
            {
                string reqID = refresh.getMDReqID().getValue();

                Instrument instrument = (provider as GSFIX).GetInstrument(reqID);

                if (instrument == null)
                {
                    return;
                }

                QuickFix42.MarketDataIncrementalRefresh.NoMDEntries group = new QuickFix42.MarketDataIncrementalRefresh.NoMDEntries();

                int    position;
                double price;
                int    size;

                SmartQuant.Data.MarketDepth depth;
                SmartQuant.Data.Quote       quote;

                for (uint i = 1; i <= refresh.getNoMDEntries().getValue(); i++)
                {
                    refresh.getGroup(i, group);

                    switch (group.getMDUpdateAction().getValue())
                    {
                    // new

                    case QuickFix.MDUpdateAction.NEW:
                    {
                        switch (group.getMDEntryType().getValue())
                        {
                        case QuickFix.MDEntryType.BID:

                            //Console.WriteLine("NEW BID");

                            price = group.getMDEntryPx().getValue();
                            size  = (int)group.getMDEntrySize().getValue();

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Bid, price, size);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote, best bid

                            if (price > instrument.Quote.Bid)
                            {
                                quote = new Quote(instrument.Quote);

                                quote.DateTime = Clock.Now;
                                quote.Bid      = price;
                                quote.BidSize  = size;

                                provider.EmitQuote(quote, instrument);
                            }

                            break;

                        case QuickFix.MDEntryType.OFFER:

                            //Console.WriteLine("NEW ASK");

                            price = group.getMDEntryPx().getValue();
                            size  = (int)group.getMDEntrySize().getValue();

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", -1, MDOperation.Insert, MDSide.Ask, price, size);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote, best ask

                            if (price < instrument.Quote.Ask)
                            {
                                quote = new Quote(instrument.Quote);

                                quote.DateTime = Clock.Now;
                                quote.Ask      = price;
                                quote.AskSize  = size;

                                provider.EmitQuote(quote, instrument);
                            }

                            break;

                        case QuickFix.MDEntryType.TRADE:

                            provider.EmitTrade(new Trade(Clock.Now, group.getMDEntryPx().getValue(), (int)group.getMDEntrySize().getValue()), instrument);

                            break;
                        }
                    }
                    break;

                    // change

                    case QuickFix.MDUpdateAction.CHANGE:
                    {
                        switch (group.getMDEntryType().getValue())
                        {
                        case QuickFix.MDEntryType.BID:

                            //Console.WriteLine("CHANGE BID!");

                            position = group.getMDEntryPositionNo().getValue() - 1;
                            size     = (int)group.getMDEntrySize().getValue();

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Bid, 0, size);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote, best bid

                            if (position == 0)
                            {
                                quote = new Quote(instrument.Quote);

                                quote.DateTime = Clock.Now;
                                quote.BidSize  = (int)group.getMDEntrySize().getValue();

                                provider.EmitQuote(quote, instrument);
                            }

                            break;

                        case QuickFix.MDEntryType.OFFER:

                            //Console.WriteLine("CHANGE ASK!");

                            position = group.getMDEntryPositionNo().getValue() - 1;
                            size     = (int)group.getMDEntrySize().getValue();

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Update, MDSide.Ask, 0, size);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote, best bid

                            if (position == 0)
                            {
                                quote = new Quote(instrument.Quote);

                                quote.DateTime = Clock.Now;
                                quote.AskSize  = (int)group.getMDEntrySize().getValue();

                                provider.EmitQuote(quote, instrument);
                            }

                            break;
                        }
                    }
                    break;

                    // delete

                    case QuickFix.MDUpdateAction.DELETE:
                    {
                        switch (group.getMDEntryType().getValue())
                        {
                        case QuickFix.MDEntryType.BID:

                            //Console.WriteLine("DELETE BID");

                            position = group.getMDEntryPositionNo().getValue() - 1;

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Bid, 0, 0);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote

                            if (position == 0)
                            {
                                Quote newQuote = instrument.OrderBook.GetQuote(0);

                                newQuote.DateTime = Clock.Now;

                                provider.EmitQuote(newQuote, instrument);
                            }
                            break;

                        case QuickFix.MDEntryType.OFFER:

                            //Console.WriteLine("DELETE ASK");

                            position = group.getMDEntryPositionNo().getValue() - 1;

                            // market depth

                            depth = new SmartQuant.Data.MarketDepth(Clock.Now, "", position, MDOperation.Delete, MDSide.Ask, 0, 0);

                            provider.EmitMarketDepth(depth, instrument);

                            // quote

                            if (position == 0)
                            {
                                Quote newQuote = instrument.OrderBook.GetQuote(0);

                                newQuote.DateTime = Clock.Now;

                                provider.EmitQuote(newQuote, instrument);
                            }

                            break;
                        }
                    }
                    break;
                    }
                }

                group.Dispose();
            }
        }
コード例 #57
0
ファイル: FixServerAcceptor.cs プロジェクト: radtek/Gradual
 public virtual void OnLogout(QuickFix.SessionID session)
 {
     logger.InfoFormat("OnLogout() sessionID[{0}]", session.ToString());
 }
コード例 #58
0
 /// <summary>
 /// Implement this to provide custom reaction behavior to an ad-hoc session removal.
 /// (This is called after the session is removed.)
 /// </summary>
 /// <param name="sessionID">ID of session that was removed</param>
 protected virtual void OnRemove(SessionID sessionID)
 {
 }
コード例 #59
0
ファイル: FixInitiator.cs プロジェクト: radtek/Gradual
        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!");
        }
コード例 #60
0
ファイル: ChannelTcpConflated.cs プロジェクト: radtek/Gradual
        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!");
        }