Exemplo n.º 1
0
        protected void NextSequenceReset(Message sequenceReset)
        {
            bool isGapFill = false;

            if (sequenceReset.IsSetField(Fields.Tags.GapFillFlag))
            {
                isGapFill = sequenceReset.GetBoolean(Fields.Tags.GapFillFlag);
            }

            if (!Verify(sequenceReset, isGapFill, isGapFill))
            {
                return;
            }

            if (sequenceReset.IsSetField(Fields.Tags.NewSeqNo))
            {
                int newSeqNo = sequenceReset.GetInt(Fields.Tags.NewSeqNo);
                this.Log.OnEvent("Received SequenceReset FROM: " + state_.GetNextTargetMsgSeqNum() + " TO: " + newSeqNo);

                if (newSeqNo > state_.GetNextTargetMsgSeqNum())
                {
                    state_.SetNextTargetMsgSeqNum(newSeqNo);
                }
                else
                {
                    if (newSeqNo < state_.GetNextTargetMsgSeqNum())
                    {
                        GenerateReject(sequenceReset, FixValues.SessionRejectReason.VALUE_IS_INCORRECT);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void NextLogon(Message logon)
        {
            Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false);
            if (logon.IsSetField(resetSeqNumFlag))
            {
                logon.GetField(resetSeqNumFlag);
            }
            state_.ReceivedReset = resetSeqNumFlag.Obj;

            if (!state_.IsInitiator && this.ResetOnLogon)
            {
                state_.Reset();
            }

            if (!Verify(logon, false, true))
            {
                return;
            }

            if (!IsGoodTime(logon))
            {
                this.Log.OnEvent("Logon had bad sending time");
                Disconnect("bad sending time");
                return;
            }

            state_.ReceivedLogon = true;
            this.Log.OnEvent("Received logon");
            if (!state_.IsInitiator)
            {
                int heartBtInt = logon.GetInt(Fields.Tags.HeartBtInt);
                state_.HeartBtInt = heartBtInt;
                GenerateLogon(heartBtInt);
                this.Log.OnEvent("Responding to logon request");
            }

            state_.SentReset     = false;
            state_.ReceivedReset = false;

            int msgSeqNum = logon.Header.GetInt(Fields.Tags.MsgSeqNum);

            if (IsTargetTooHigh(msgSeqNum) && !resetSeqNumFlag.Obj)
            {
                DoTargetTooHigh(logon, msgSeqNum);
            }
            else
            {
                state_.IncrNextTargetMsgSeqNum();
                NextQueued();
            }
        }
Exemplo n.º 3
0
        protected void NextSequenceReset(Message sequenceReset)
        {
            bool isGapFill = false;
            if (sequenceReset.IsSetField(Fields.Tags.GapFillFlag))
                isGapFill = sequenceReset.GetBoolean(Fields.Tags.GapFillFlag);

            if (!Verify(sequenceReset, isGapFill, isGapFill))
                return;

            if (sequenceReset.IsSetField(Fields.Tags.NewSeqNo))
            {
                int newSeqNo = sequenceReset.GetInt(Fields.Tags.NewSeqNo);
                this.Log.OnEvent("Received SequenceReset FROM: " + state_.GetNextTargetMsgSeqNum() + " TO: " + newSeqNo);

                if (newSeqNo > state_.GetNextTargetMsgSeqNum())
                {
                    state_.SetNextTargetMsgSeqNum(newSeqNo);
                }
                else
                {
                    if (newSeqNo < state_.GetNextTargetMsgSeqNum())
                        GenerateReject(sequenceReset, FixValues.SessionRejectReason.VALUE_IS_INCORRECT);
                }
            }
        }
Exemplo n.º 4
0
        protected void NextResendRequest(Message resendReq)
        {
            try
            {
                int msgSeqNum = 0;
                if (!(this.IgnorePossDupResendRequests && resendReq.Header.IsSetField(Tags.PossDupFlag)))
                {
                    int begSeqNo = resendReq.GetInt(Fields.Tags.BeginSeqNo);
                    int endSeqNo = resendReq.GetInt(Fields.Tags.EndSeqNo);
                    this.Log.OnEvent("Got resend request from " + begSeqNo + " to " + endSeqNo);

                    if ((endSeqNo == 999999) || (endSeqNo == 0))
                    {
                        endSeqNo = state_.GetNextSenderMsgSeqNum() - 1;
                    }

                    if (!PersistMessages)
                    {
                        endSeqNo++;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                            endSeqNo = next;
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                        return;
                    }

                    List<string> messages = new List<string>();
                    state_.Get(begSeqNo, endSeqNo, messages);
                    int current = begSeqNo;
                    int begin = 0;
                    foreach (string msgStr in messages)
                    {
                        Message msg = new Message(msgStr);
                        msgSeqNum = msg.Header.GetInt(Tags.MsgSeqNum);

                        if ((current != msgSeqNum) && begin == 0)
                        {
                            begin = current;
                        }

                        if (IsAdminMessage(msg))
                        {
                            if (begin == 0)
                            {
                                begin = msgSeqNum;
                            }
                        }
                        else
                        {

                            initializeResendFields(msg);
                            if (begin != 0)
                            {
                                GenerateSequenceReset(resendReq, begin, msgSeqNum);
                            }
                            Send(msg.ToString());
                            begin = 0;
                        }
                        current = msgSeqNum + 1;
                    }

                    if (begin != 0)
                    {
                        GenerateSequenceReset(resendReq, begin, msgSeqNum + 1);
                    }

                    if (endSeqNo > msgSeqNum)
                    {
                        endSeqNo = endSeqNo + 1;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                        {
                            endSeqNo = next;
                        }
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                    }
                }
                msgSeqNum = resendReq.Header.GetInt(Tags.MsgSeqNum);
                if (!IsTargetTooHigh(msgSeqNum) && !IsTargetTooLow(msgSeqNum))
                {
                    state_.IncrNextTargetMsgSeqNum();
                }

            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("ERROR during resend request " + e.Message);
            }
        }
Exemplo n.º 5
0
        protected void NextLogon(Message logon)
        {
            Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false);
            if (logon.IsSetField(resetSeqNumFlag))
                logon.GetField(resetSeqNumFlag);
            state_.ReceivedReset = resetSeqNumFlag.Obj;

            if (!state_.IsInitiator && this.ResetOnLogon)
                state_.Reset();

            if (!Verify(logon, false, true))
                return;

            if (!IsGoodTime(logon))
            {
                this.Log.OnEvent("Logon had bad sending time");
                Disconnect("bad sending time");
                return;
            }

            state_.ReceivedLogon = true;
            this.Log.OnEvent("Received logon");
            if (!state_.IsInitiator)
            {
                int heartBtInt = logon.GetInt(Fields.Tags.HeartBtInt);
                state_.HeartBtInt = heartBtInt;
                GenerateLogon(logon);
                this.Log.OnEvent("Responding to logon request");
            }

            state_.SentReset = false;
            state_.ReceivedReset = false;

            int msgSeqNum = logon.Header.GetInt(Fields.Tags.MsgSeqNum);
            if (IsTargetTooHigh(msgSeqNum) && !resetSeqNumFlag.Obj)
            {
                DoTargetTooHigh(logon, msgSeqNum);
            }
            else
            {
                state_.IncrNextTargetMsgSeqNum();
                NextQueued();
            }

            if (this.IsLoggedOn)
                this.Application.OnLogon(this.SessionID);
        }
Exemplo n.º 6
0
        /// <summary>
        /// FIXME don't do so much operator new here
        /// </summary>
        /// <param name="heartBtInt"></param>
        /// <returns></returns>
        protected bool GenerateLogon(Message otherLogon)
        {
            Message logon = msgFactory_.Create(this.SessionID.BeginString, Fields.MsgType.LOGON);
            logon.SetField(new Fields.EncryptMethod(0));
            if (this.SessionID.IsFIXT)
                logon.SetField(new Fields.DefaultApplVerID(this.SenderDefaultApplVerID));
            if (state_.ReceivedReset)
                logon.SetField(new Fields.ResetSeqNumFlag(true));
            logon.SetField(new Fields.HeartBtInt(otherLogon.GetInt(Tags.HeartBtInt)));
            if (this.EnableLastMsgSeqNumProcessed)
                logon.Header.SetField(new Fields.LastMsgSeqNumProcessed(otherLogon.Header.GetInt(Tags.MsgSeqNum)));

            InitializeHeader(logon);
            state_.SentLogon = SendRaw(logon, 0);
            return state_.SentLogon;
        }
Exemplo n.º 7
0
        protected void NextResendRequest(Message resendReq)
        {
            if (!Verify(resendReq, false, false))
                return;
            try
            {
                int msgSeqNum = 0;
                if (!(this.IgnorePossDupResendRequests && resendReq.Header.IsSetField(Tags.PossDupFlag)))
                {
                    int begSeqNo = resendReq.GetInt(Fields.Tags.BeginSeqNo);
                    int endSeqNo = resendReq.GetInt(Fields.Tags.EndSeqNo);
                    this.Log.OnEvent("Got resend request from " + begSeqNo + " to " + endSeqNo);

                    if ((endSeqNo == 999999) || (endSeqNo == 0))
                    {
                        endSeqNo = state_.GetNextSenderMsgSeqNum() - 1;
                    }

                    if (!PersistMessages)
                    {
                        endSeqNo++;
                        int next = state_.GetNextSenderMsgSeqNum();
                        if (endSeqNo > next)
                            endSeqNo = next;
                        GenerateSequenceReset(resendReq, begSeqNo, endSeqNo);
                        return;
                    }

                    List<string> messages = new List<string>();
                    state_.Get(begSeqNo, endSeqNo, messages);
                    int current = begSeqNo;
                    int begin = 0;
                    foreach (string msgStr in messages)
                    {
                        Message msg = new Message();
                        msg.FromString(msgStr, true, this.SessionDataDictionary, this.ApplicationDataDictionary, msgFactory_);
                        msgSeqNum = msg.Header.GetInt(Tags.MsgSeqNum);

                        if ((current != msgSeqNum) && begin == 0)
                        {
                            begin = current;
                        }

                        if (IsAdminMessage(msg) && !(this.ResendSessionLevelRejects && msg.Header.GetString(Tags.MsgType) == MsgType.REJECT))
                        {
                            if (begin == 0)
                            {
                                begin = msgSeqNum;
                            }
                        }
                        else
                        {

                            initializeResendFields(msg);
                            if(!ResendApproved(msg, SessionID)) 
                            {
                                continue;
                            }

                            if (begin != 0)
                            {
                                GenerateSequenceReset(resendReq, begin, msgSeqNum);
                            }
                            Send(msg.ToString());
                            begin = 0;
                        }
                        current = msgSeqNum + 1;
                    }

                    int nextSeqNum = state_.GetNextSenderMsgSeqNum();
                    if (++endSeqNo > nextSeqNum)
                    {
                        endSeqNo = nextSeqNum;
                    }

                    if (begin == 0)
                    {
                        begin = current;
                    }

                    if (endSeqNo > begin)
                    {
                        GenerateSequenceReset(resendReq, begin, endSeqNo);
                    }
                }
                msgSeqNum = resendReq.Header.GetInt(Tags.MsgSeqNum);
                if (!IsTargetTooHigh(msgSeqNum) && !IsTargetTooLow(msgSeqNum))
                {
                    state_.IncrNextTargetMsgSeqNum();
                }

            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("ERROR during resend request " + e.Message);
            }
        }
Exemplo n.º 8
0
        public void SetFieldsTest()
        {
            var message = new Message();
            var allocId = new AllocID("123456");
            var allocAccount = new AllocAccount("QuickFixAccount");
            var allocAccountType = new AllocAccountType(AllocAccountType.HOUSE_TRADER);
            message.SetFields(new IField[] { allocAccount, allocAccountType, allocId });

            Assert.AreEqual(true, message.IsSetField(Tags.AllocID));
            Assert.AreEqual("123456", message.GetField(Tags.AllocID));

            Assert.AreEqual(true, message.IsSetField(Tags.AllocAccount));
            Assert.AreEqual("QuickFixAccount", message.GetField(Tags.AllocAccount));

            Assert.AreEqual(true, message.IsSetField(Tags.AllocAccountType));
            Assert.AreEqual(AllocAccountType.HOUSE_TRADER, message.GetInt(Tags.AllocAccountType));
        }
Exemplo n.º 9
0
        protected void NextLogon(Message logon)
        {
            Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false);
            if (logon.IsSetField(resetSeqNumFlag))
                logon.GetField(resetSeqNumFlag);
            state_.ReceivedReset = resetSeqNumFlag.Obj;

            if (state_.ReceivedReset)
            {
                this.Log.OnEvent("Sequence numbers reset due to ResetSeqNumFlag=Y");
                if (!state_.SentReset)
                {
                    state_.Reset("Reset requested by counterparty");
                }
            }

            if (!state_.IsInitiator && this.ResetOnLogon)
                state_.Reset("ResetOnLogon");
            if (this.RefreshOnLogon)
                Refresh();

            if (!Verify(logon, false, true))
                return;

            if (!IsGoodTime(logon))
            {
                this.Log.OnEvent("Logon has bad sending time");
                Disconnect("bad sending time");
                return;
            }

            state_.ReceivedLogon = true;
            this.Log.OnEvent("Received logon");
            if (!state_.IsInitiator)
            {
                int heartBtInt = logon.GetInt(Fields.Tags.HeartBtInt);
                state_.HeartBtInt = (int)Math.Floor(heartBtInt / (double)2);
                GenerateLogon(logon);
                this.Log.OnEvent("Responding to logon request");
            }

            state_.SentReset = false;
            state_.ReceivedReset = false;

            int msgSeqNum = logon.Header.GetInt(Fields.Tags.MsgSeqNum);
            if (IsTargetTooHigh(msgSeqNum) && !resetSeqNumFlag.Obj)
            {
                DoTargetTooHigh(logon, msgSeqNum);
            }
            else
            {
                state_.IncrNextTargetMsgSeqNum();
            }

            if (this.IsLoggedOn)
                this.Application.OnLogon(this.SessionID);
        }
Exemplo n.º 10
0
        protected void NextResendRequest(Message resendReq)
        {
            try
            {
                // FIXME
                int begSeqNo = resendReq.GetInt(Fields.Tags.BeginSeqNo);
                int endSeqNo = resendReq.GetInt(Fields.Tags.EndSeqNo);
                this.Log.OnEvent("Got resend request from " + begSeqNo + " to " + endSeqNo);

                if ((endSeqNo == 999999) || (endSeqNo == 0))
                {
                    endSeqNo = state_.GetNextSenderMsgSeqNum() - 1;
                }

                List <string> messages = new List <string>();
                state_.Get(begSeqNo, endSeqNo, messages);
                int current   = begSeqNo;
                int begin     = 0;
                int msgSeqNum = 0;
                foreach (string msgStr in messages)
                {
                    Message msg = new Message(msgStr);
                    msgSeqNum = msg.Header.GetInt(Tags.MsgSeqNum);

                    if ((current != msgSeqNum) && begin == 0)
                    {
                        begin = current;
                    }

                    if (IsAdminMessage(msg))
                    {
                        if (begin == 0)
                        {
                            begin = msgSeqNum;
                        }
                    }
                    else
                    {
                        initializeResendFields(msg);
                        if (begin != 0)
                        {
                            GenerateSequenceReset(begin, msgSeqNum);
                        }
                        Send(msg.ToString());
                        begin = 0;
                    }
                    current = msgSeqNum + 1;
                }

                if (begin != 0)
                {
                    GenerateSequenceReset(begin, msgSeqNum + 1);
                }

                if (endSeqNo > msgSeqNum)
                {
                    endSeqNo = endSeqNo + 1;
                    int next = state_.GetNextSenderMsgSeqNum();
                    if (endSeqNo > next)
                    {
                        endSeqNo = next;
                    }
                    GenerateSequenceReset(begSeqNo, endSeqNo);
                }

                msgSeqNum = resendReq.Header.GetInt(Tags.MsgSeqNum);
                if (!IsTargetTooHigh(msgSeqNum) && !IsTargetTooLow(msgSeqNum))
                {
                    state_.IncrNextTargetMsgSeqNum();
                }
            }
            catch (System.Exception e)
            {
                this.Log.OnEvent("ERROR during resend request " + e.Message);
            }
        }
Exemplo n.º 11
0
        public static QuickFix.FIX44.OrderCancelReject Fix44Reject2OrderCancelReject(QuickFix.Message msgReject, QuickFix.Message msgOri)
        {
            try
            {
                QuickFix.FIX44.OrderCancelReject ocr = new QuickFix.FIX44.OrderCancelReject();
                if (msgOri.IsSetField(Tags.OrderID))
                {
                    ocr.Set(new OrderID(msgOri.GetString(Tags.OrderID)));
                }
                else
                {
                    ocr.Set(new OrderID("NONE"));
                }
                ocr.Set(new ClOrdID(msgOri.GetString(Tags.ClOrdID)));           // mandatory
                ocr.Set(new OrigClOrdID(msgOri.GetString(Tags.OrigClOrdID)));   // mandatory
                ocr.Set(new OrdStatus(OrdStatus.REJECTED));                     // mandatory
                if (msgOri.IsSetField(Tags.Account))
                {
                    ocr.SetField(new Account(msgOri.GetString(Tags.Account)));
                }
                if (msgOri.Header.GetString(Tags.MsgType).Equals(MsgType.ORDER_CANCEL_REQUEST)) // mandatory
                {
                    ocr.Set(new CxlRejResponseTo('1'));
                }
                else
                {
                    ocr.Set(new CxlRejResponseTo('2'));
                }
                if (msgReject.IsSetField(Tags.Text))
                {
                    ocr.Set(new Text(msgReject.GetString(Tags.Text)));
                }
                // ocr.Set(new CxlRejReason(2137));

                // Tratamento tag SecondaryOrderID
                // Se nao vier na mensagem busca pelo TO
                //if (msgOri.IsSetField(Tags.SecondaryOrderID))
                //{
                //    ocr.Set(new SecondaryOrderID(msgOri.GetString(Tags.SecondaryOrderID)));
                //}
                //else
                //{
                //    if (null != to)
                //    {
                //        if (!string.IsNullOrEmpty(to.SecondaryOrderID))
                //            ocr.Set(new SecondaryOrderID(to.SecondaryOrderID));
                //
                //        if (!string.IsNullOrEmpty(to.TradeDate))
                //            ocr.Set(new TradeDate(to.TradeDate));
                //    }
                //}
                int len = msgOri.GetInt(Tags.NoPartyIDs);
                for (int i = 0; i < len; i++)
                {
                    Group grp = msgOri.GetGroup(i + 1, Tags.NoPartyIDs);
                    ocr.AddGroup(grp);
                }
                ocr.Set(new Symbol(msgOri.GetString(Tags.Symbol)));
                if (msgOri.IsSetField(Tags.SecurityID))
                {
                    ocr.Set(new SecurityID(msgOri.GetField(Tags.SecurityID)));
                }
                if (msgOri.IsSetField(Tags.SecurityIDSource))
                {
                    ocr.Set(new SecurityIDSource(msgOri.GetField(Tags.SecurityIDSource)));
                }
                ocr.Set(new Side(msgOri.GetChar(Tags.Side)));
                if (msgOri.IsSetField(Tags.Memo))
                {
                    ocr.Set(new Memo(msgOri.GetString(Tags.Memo)));
                }
                return(ocr);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44Reject2OrderCancelReject(): " + ex.Message, ex);
                return(null);
            }
        }
Exemplo n.º 12
0
        public static QuickFix.FIX44.ExecutionReport Fix44Rejection2ExecutionReport(QuickFix.Message msgReject, QuickFix.Message msgOri)
        {
            try
            {
                QuickFix.FIX44.ExecutionReport er = new QuickFix.FIX44.ExecutionReport();
                if (msgOri.IsSetField(Tags.OrderID))
                {
                    er.Set(new OrderID(msgOri.GetString(Tags.OrderID)));
                }
                else
                {
                    er.Set(new OrderID("NONE"));
                }

                if (msgOri.IsSetField(Tags.ClOrdID))
                {
                    er.Set(new ClOrdID(msgOri.GetField(Tags.ClOrdID)));
                }
                if (msgOri.IsSetField(Tags.OrigClOrdID))
                {
                    er.Set(new OrigClOrdID(msgOri.GetField(Tags.OrigClOrdID)));
                }
                // Fazer atribuicao dos PartyIDs da mensagem original
                int len = msgOri.GetInt(Tags.NoPartyIDs);
                for (int i = 0; i < len; i++)
                {
                    Group grp = msgOri.GetGroup(i + 1, Tags.NoPartyIDs);
                    er.AddGroup(grp);
                }
                er.Set(new ExecID(DateTime.Now.ToString("yyyyMMddHHmmssfff")));
                er.Set(new ExecType(ExecType.REJECTED));
                er.Set(new OrdStatus(OrdStatus.REJECTED));
                if (msgOri.IsSetField(Tags.Account))
                {
                    er.Set(new Account(msgOri.GetField(Tags.Account)));
                }
                er.Set(new Symbol(msgOri.GetField(Tags.Symbol)));
                if (msgOri.IsSetField(Tags.SecurityID))
                {
                    er.Set(new SecurityID(msgOri.GetField(Tags.SecurityID)));
                }
                if (msgOri.IsSetField(Tags.SecurityIDSource))
                {
                    er.Set(new SecurityIDSource(msgOri.GetField(Tags.SecurityIDSource)));
                }
                er.Set(new Side(msgOri.GetChar(Tags.Side)));
                er.Set(new OrderQty(msgOri.GetDecimal(Tags.OrderQty)));
                if (msgOri.IsSetField(Tags.OrdType))
                {
                    er.Set(new OrdType(msgOri.GetChar(Tags.OrdType)));
                }
                if (msgOri.IsSetField(Tags.Price))
                {
                    er.Set(new Price(msgOri.GetDecimal(Tags.Price)));
                }
                if (msgOri.IsSetField(Tags.StopPx))
                {
                    er.Set(new StopPx(msgOri.GetDecimal(Tags.StopPx)));
                }
                if (msgOri.IsSetField(Tags.TimeInForce))
                {
                    er.Set(new TimeInForce(msgOri.GetChar(Tags.TimeInForce)));
                }
                if (msgOri.IsSetField(Tags.ExpireDate))
                {
                    er.Set(new ExpireDate(msgOri.GetField(Tags.ExpireDate)));
                }
                er.Set(new LeavesQty(0));
                er.Set(new CumQty(0));
                er.Set(new AvgPx(Decimal.Zero));
                DateTime transact = DateTime.UtcNow;
                er.Set(new TransactTime(transact));
                if (msgOri.IsSetField(Tags.MaxFloor))
                {
                    er.Set(new MaxFloor(msgOri.GetDecimal(Tags.MaxFloor)));
                }
                if (msgOri.IsSetField(Tags.Memo))
                {
                    er.SetField(new Memo(msgOri.GetString(Tags.Memo)));
                }

                if (msgReject.IsSetField(Tags.Text))
                {
                    er.Set(new Text(msgReject.GetField(Tags.Text)));
                }
                if (msgReject.IsSetField(Tags.OrderID))
                {
                    er.Set(new OrderID(msgReject.GetField(Tags.OrderID)));
                }

                return(er);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44Rejection2ExecutionReport(): " + ex.Message, ex);
                return(null);
            }
        }
Exemplo n.º 13
0
        public static QuickFix.FIX42.OrderCancelReject Fix42Reject2OrderCancelReject(QuickFix.Message msgReject, QuickFix.Message msgOri)
        {
            try
            {
                QuickFix.FIX42.OrderCancelReject ocr = new QuickFix.FIX42.OrderCancelReject();

                if (msgOri.IsSetField(Tags.OrderID))
                {
                    ocr.Set(new OrderID(msgOri.GetString(Tags.OrderID)));
                }
                else
                {
                    ocr.Set(new OrderID("NONE"));
                }
                if (msgOri.IsSetField(Tags.SecondaryOrderID))
                {
                    ocr.Set(new SecondaryOrderID(msgOri.GetString(Tags.SecondaryOrderID)));
                }
                if (msgOri.IsSetField(Tags.ClOrdID))
                {
                    ocr.Set(new ClOrdID(msgOri.GetString(Tags.ClOrdID)));
                }
                if (msgOri.IsSetField(Tags.OrigClOrdID))
                {
                    ocr.Set(new OrigClOrdID(msgOri.GetString(Tags.OrigClOrdID)));
                }
                ocr.Set(new OrdStatus(OrdStatus.REJECTED));
                // if (msgOri.IsSetField(Tags.ClientID)) ocr.Set(new ClientID(msgOri.GetString(Tags.ClientID))); // not found on 4.4EP
                // TODO[FF] - Verificar a montagem do execbroker a partir de party ids
                // if (msgOri.IsSetField(Tags.ExecBroker)) ocr.Set(new ExecBroker(msgOri.GetString(Tags.ExecBroker))); // not found on 4.4EP
                if (msgOri.IsSetField(Tags.ListID))
                {
                    ocr.Set(new ListID(msgOri.GetString(Tags.ListID)));
                }
                if (msgOri.IsSetField(Tags.Account))
                {
                    ocr.Set(new Account(msgOri.GetString(Tags.Account)));
                }
                if (msgOri.IsSetField(Tags.TransactTime))
                {
                    ocr.Set(new TransactTime(msgOri.GetDateTime(Tags.TransactTime)));
                }
                if (msgOri.Header.GetString(Tags.MsgType).Equals(MsgType.ORDER_CANCEL_REQUEST)) // mandatory
                {
                    ocr.Set(new CxlRejResponseTo('1'));
                }
                else
                {
                    ocr.Set(new CxlRejResponseTo('2'));
                }
                //if (msgOri.IsSetField(Tags.CxlRejReason)) ocr.Set(new CxlRejReason(msgOri.GetInt(Tags.CxlRejReason)));
                if (msgOri.IsSetField(Tags.CxlRejReason))
                {
                    ocr.Set(new CxlRejReason(CxlRejReason.BROKER_OPTION));
                }
                if (msgOri.IsSetField(Tags.Text))
                {
                    ocr.Set(new Text(msgOri.GetString(Tags.Text)));
                }
                if (msgOri.IsSetField(Tags.EncodedTextLen))
                {
                    ocr.Set(new EncodedTextLen(msgOri.GetInt(Tags.EncodedTextLen)));
                }
                if (msgOri.IsSetField(Tags.EncodedText))
                {
                    ocr.Set(new EncodedText(msgOri.GetString(Tags.EncodedText)));
                }
                if (msgOri.IsSetField(Tags.Memo))
                {
                    ocr.SetField(new Memo(msgOri.GetString(Tags.Memo)));
                }

                /*
                 * if (msgOri.IsSetField(Tags.OrderID))
                 *  ocr.Set(new OrderID(msgOri.GetString(Tags.OrderID)));
                 * else
                 *  ocr.Set(new OrderID("NONE"));
                 * ocr.Set(new ClOrdID(msgOri.GetString(Tags.ClOrdID)));           // mandatory
                 * ocr.Set(new OrigClOrdID(msgOri.GetString(Tags.OrigClOrdID)));   // mandatory
                 * ocr.Set(new OrdStatus(OrdStatus.REJECTED));                     // mandatory
                 * if (msgOri.IsSetField(Tags.Account))
                 *  ocr.SetField(new Account(msgOri.GetString(Tags.Account)));
                 * if (msgOri.Header.GetString(Tags.MsgType).Equals(MsgType.ORDER_CANCEL_REQUEST)) // mandatory
                 *  ocr.Set(new CxlRejResponseTo('1'));
                 * else
                 *  ocr.Set(new CxlRejResponseTo('2'));
                 * if (msgReject.IsSetField(Tags.Text))
                 *  ocr.Set(new Text(msgReject.GetString(Tags.Text)));
                 * int len = msgOri.GetInt(Tags.NoPartyIDs);
                 * for (int i = 0; i < len; i++)
                 * {
                 *  Group grp = msgOri.GetGroup(i + 1, Tags.NoPartyIDs);
                 *  ocr.AddGroup(grp);
                 * }
                 * ocr.SetField(new Symbol(msgOri.GetString(Tags.Symbol)));
                 * if (msgOri.IsSetField(Tags.SecurityID)) ocr.SetField(new SecurityID(msgOri.GetField(Tags.SecurityID)));
                 * if (msgOri.IsSetField(Tags.SecurityIDSource)) ocr.SetField(new SecurityIDSource(msgOri.GetField(Tags.SecurityIDSource)));
                 * ocr.SetField(new Side(msgOri.GetChar(Tags.Side)));
                 * if (msgOri.IsSetField(Tags.Memo))
                 *  ocr.SetField(new Memo(msgOri.GetString(Tags.Memo)));
                 */
                return(ocr);
            }
            catch (Exception ex)
            {
                logger.Error("Fix42Reject2OrderCancelReject(): " + ex.Message, ex);
                return(null);
            }
        }