Beispiel #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////
        //////////////////////////////////////////////////////////////////////////////////////////////
        #region "FIX42 Conversions to Fix44"



        /*
         * public static QuickFix.FIX44.SequenceReset Fix42SR_2_Fix44SR(QuickFix.FIX42.SequenceReset sr42)
         * {
         *  try
         *  {
         *      QuickFix.FIX44.SequenceReset sr44 = new QuickFix.FIX44.SequenceReset();
         *      _fix42Header_2_Fix44Header(sr42.Header, sr44.Header);
         *
         *      if (sr42.IsSetNewSeqNo()) sr44.Set(new NewSeqNo(sr42.NewSeqNo.getValue()));
         *      if (sr42.IsSetGapFillFlag()) sr44.Set(new GapFillFlag(sr42.GapFillFlag.getValue()));
         *      return sr44;
         *  }
         *  catch (Exception ex)
         *  {
         *      logger.Error("Fix42SR_2_Fix44SR(): Problemas na conversao da mensagem SR: " + ex.Message, ex);
         *      return null;
         *  }
         * }
         */
        public static void Generate44RejectMessage(QuickFix.Message msg, SessionID s, string msgType, Exception ex, SessionAcceptor ssAcceptor, string msgText)
        {
            try
            {
                if (null != ex)
                {
                    string aux = string.Format("QuickFix44 MsgType: [{0}], Message: [{1}]", msgType, ex.Message);
                    logger.Error(aux, ex);
                }

                QuickFix.FIX44.Reject rej = new QuickFix.FIX44.Reject();
                rej.Set(new RefMsgType(msgType));
                rej.Set(new RefSeqNum(msg.Header.GetInt(Tags.MsgSeqNum)));
                if (string.IsNullOrEmpty(msgText))
                {
                    rej.Set(new Text("System unavaliable")); // Mensagem generica para nao expor possiveis erros de aplicacao
                }
                else
                {
                    rej.Set(new Text(msgText));
                }

                if (msgType.Equals(MsgType.ORDER_CANCEL_REQUEST) || msgType.Equals(MsgType.ORDER_CANCEL_REPLACE_REQUEST))
                {
                    QuickFix.FIX44.OrderCancelReject ocr = Fix44Translator.Fix44Reject2OrderCancelReject(rej, msg);
                    Session.SendToTarget(ocr, s);
                    if (null != ssAcceptor)
                    {
                        ssAcceptor.Send2DropCopy(ocr);
                    }
                }
                else
                {
                    QuickFix.FIX44.ExecutionReport er = Fix44Translator.Fix44Rejection2ExecutionReport(rej, msg);
                    Session.SendToTarget(er, s);
                    if (null != ssAcceptor)
                    {
                        ssAcceptor.Send2DropCopy(er);
                    }
                }
            }
            catch (Exception exC)
            {
                logger.Error("Problemas na geracao de mensagem de reject (tratamento de excecoes) de mensagem fix 4.2: " + exC.Message, exC);
            }
        }
Beispiel #2
0
        public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s)
        {
            string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";

            QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
                new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
            ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
            ocj.Text         = new Text("Executor does not support order cancel/replaces");

            try
            {
                Session.SendToTarget(ocj, s);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #3
0
        public void OnMessage(QuickFix.FIX44.OrderCancelReplaceRequest msg, SessionID s)
        {
            string orderid = (msg.IsSetOrderID()) ? msg.OrderID.Obj : "unknown orderID";
            QuickFix.FIX44.OrderCancelReject ocj = new QuickFix.FIX44.OrderCancelReject(
                new OrderID(orderid), msg.ClOrdID, msg.OrigClOrdID, new OrdStatus(OrdStatus.REJECTED), new CxlRejResponseTo(CxlRejResponseTo.ORDER_CANCEL_REPLACE_REQUEST));
            ocj.CxlRejReason = new CxlRejReason(CxlRejReason.OTHER);
            ocj.Text = new Text("Executor does not support order cancel/replaces");

            try
            {
                Session.SendToTarget(ocj, s);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
Beispiel #4
0
 public void OnMessage(QuickFix.FIX44.OrderCancelReject m, SessionID s)
 {
     Console.WriteLine("Received order cancel reject");
 }
Beispiel #5
0
 public void OnMessage(QuickFix.FIX44.OrderCancelReject m, SessionID s)
 {
 }
Beispiel #6
0
 public void OnMessage(QuickFix.FIX44.OrderCancelReject msg, QuickFix.SessionID s)
 {
     _messageSink.Error(
         () => string.Format("OrderCanel rejected for order ClOrdID {0}", msg.ClOrdID));
 }
Beispiel #7
0
 public void OnMessage(QuickFix.FIX44.OrderCancelReject msg, SessionID sessionID)
 {
     OrderCancelCallback?.Invoke(true);
     OrderCancelCallback = null;
     Log.Write($"Order cancel error: {msg.GetString(Tags.Text)}", 1);
 }
Beispiel #8
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);
            }
        }
Beispiel #9
0
 public void OnMessage(QuickFix.FIX44.OrderCancelReject m, SessionID s)
 {
     Logger.Instance().Log($"REPLY (OrderCancelReject) => {m.ToString()}");
 }
Beispiel #10
0
        public static QuickFix.FIX42.OrderCancelReject Fix44OCR_2_Fix42OCR(QuickFix.FIX44.OrderCancelReject ocrj44)
        {
            try
            {
                // TODO [FF] - Efetuar a conversao do Fix44 para Fix42 de OrderCancelReject
                QuickFix.FIX42.OrderCancelReject ocrj42 = new QuickFix.FIX42.OrderCancelReject();

                if (ocrj44.IsSetOrderID())
                {
                    ocrj42.Set(new OrderID(ocrj44.OrderID.getValue()));
                }
                if (ocrj44.IsSetSecondaryOrderID())
                {
                    ocrj42.Set(new SecondaryOrderID(ocrj44.SecondaryOrderID.getValue()));
                }
                // if (ocrj44.IsSetSecondaryClOrdID()) ocrj42.Set(new SecondaryClOrdID(ocrj44.SecondaryClOrdID.getValue())); // Not Found on 4.2
                if (ocrj44.IsSetClOrdID())
                {
                    ocrj42.Set(new ClOrdID(ocrj44.ClOrdID.getValue()));
                }
                // if (ocrj44.IsSetClOrdLinkID()) ocrj42.Set(new ClOrdLinkID(ocrj44.ClOrdLinkID.getValue())); // Not Found on 4.2
                if (ocrj44.IsSetOrigClOrdID())
                {
                    ocrj42.Set(new OrigClOrdID(ocrj44.OrigClOrdID.getValue()));
                }
                if (ocrj44.IsSetOrdStatus())
                {
                    ocrj42.Set(new OrdStatus(ocrj44.OrdStatus.getValue()));
                }
                // if (ocrj44.IsSetWorkingIndicator()) ocrj42.Set(new WorkingIndicator(ocrj44.WorkingIndicator.getValue())); // Not found on 4.2
                // if (ocrj44.IsSetOrigOrdModTime()) ocrj42.Set(new OrigOrdModTime(ocrj44.OrigOrdModTime.getValue())); // Not found on 4.2
                if (ocrj44.IsSetListID())
                {
                    ocrj42.Set(new ListID(ocrj44.ListID.getValue()));
                }
                if (ocrj44.IsSetAccount())
                {
                    ocrj42.Set(new Account(ocrj44.Account.getValue()));
                }
                // if (ocrj44.IsSetAcctIDSource()) ocrj42.Set(new AcctIDSource(ocrj44.AcctIDSource.getValue())); // Not found on 4.2
                // if (ocrj44.IsSetAccountType()) ocrj42.Set(new AccountType(ocrj44.AccountType.getValue())); // Not found on 4.2
                // if (ocrj44.IsSetTradeOriginationDate()) ocrj42.Set(new TradeOriginationDate(ocrj44.TradeOriginationDate.getValue())); // Not found on 4.2
                // if (ocrj44.IsSetTradeDate()) ocrj42.Set(new TradeDate(ocrj44.TradeDate.getValue())); // Not found on 4.2
                if (ocrj44.IsSetTransactTime())
                {
                    ocrj42.Set(new TransactTime(ocrj44.TransactTime.getValue()));
                }
                if (ocrj44.IsSetCxlRejResponseTo())
                {
                    ocrj42.Set(new CxlRejResponseTo(ocrj44.CxlRejResponseTo.getValue()));
                }
                // if (ocrj44.IsSetCxlRejReason()) ocrj42.Set(new CxlRejReason(ocrj44.CxlRejReason.getValue()));
                // TODO [FF]: Verify value pattern: Set to "2": BROKER OPTION and describe rejection in text field
                if (ocrj44.IsSetCxlRejReason())
                {
                    ocrj42.Set(new CxlRejReason(CxlRejReason.BROKER_OPTION));
                }
                if (ocrj44.IsSetText())
                {
                    ocrj42.Set(new Text(ocrj44.Text.getValue()));
                }
                if (ocrj44.IsSetEncodedTextLen())
                {
                    ocrj42.Set(new EncodedTextLen(ocrj44.EncodedTextLen.getValue()));
                }
                if (ocrj44.IsSetEncodedText())
                {
                    ocrj42.Set(new EncodedText(ocrj44.EncodedText.getValue()));
                }
                if (ocrj44.IsSetMemo())
                {
                    ocrj42.SetField(new Memo(ocrj44.Memo.getValue()));
                }

                return(ocrj42);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44OCR_2_Fix42OCR(): " + ex.Message, ex);
                return(null);
            }
        }