Example #1
0
        public void RepeatingGroupParseGroupTest()
        {
            String data = "8=FIX.4.4\x01" + "9=309\x01" + "35=8\x01" + "49=ASX\x01" + "56=CL1_FIX44\x01" + "34=4\x01" + "52=20060324-01:05:58\x01" + ""
                          + "17=X-B-WOW-1494E9A0:58BD3F9D-1109\x01" + "150=D\x01" + "39=0\x01" + "11=184271\x01" + "38=200\x01" + "198=1494E9A0:58BD3F9D\x01" + ""
                          + "526=4324\x01" + "37=B-WOW-1494E9A0:58BD3F9D\x01" + "55=WOW\x01" + "54=1\x01" + "151=200\x01" + "14=0\x01" + "40=2\x01" + "44=15\x01" + "59=1\x01" + "6=0\x01" + ""
                          + "453=3\x01"
                          + "448=AAA35791\x01" + "447=D\x01" + "452=3\x01" + "802=1\x01" + "523=OHAI123\x01"
                          + "448=8\x01" + "447=D\x01" + "452=4\x01" + "448=FIX11\x01" + "447=D\x01" + "452=36\x01" + ""
                          + "60=20060320-03:34:29\x01" + "10=169\x01" + "";
            var msg = new QuickFix.FIX44.ExecutionReport();
            var dd  = new QuickFix.DataDictionary.DataDictionary();

            dd.Load("../../../spec/fix/FIX44.xml");
            msg.FromString(data, false, dd, dd, _defaultMsgFactory);

            var grp = msg.GetGroup(1, Tags.NoPartyIDs);

            Assert.That(grp.GetString(Tags.PartyID), Is.EqualTo("AAA35791"));
            grp = msg.GetGroup(3, Tags.NoPartyIDs);
            Assert.That(grp.GetString(Tags.PartyID), Is.EqualTo("FIX11"));
        }
Example #2
0
        public void FromString_Groups_NoFactory()
        {
            // issue 179
            var dd = new QuickFix.DataDictionary.DataDictionary();

            dd.Load("../../../spec/fix/FIX44.xml");

            string[] msgFields =
            {
                // header
                "8=FIX.4.4",              "9=638",          "35=8",             "34=360",          "49=BLPTSOX",                  "52=20130321-15:21:23", "56=THINKTSOX",         "57=6804469",                "128=ZERO",
                // non-group body fields
                "6=122.255",              "11=61101189",    "14=1990000",       "15=GBP",          "17=VCON:20130321:50018:5:12", "22=4",                 "31=122.255",           "32=1990000",
                "37=116",                 "38=1990000",     "39=2",             "48=GB0032452392", "54=1",                        "55=[N/A]",             "60=20130321-15:21:23", "64=20130322",               "75=20130321",
                "106=UK TSY 4 1/4% 2036", "118=2436321.85", "150=F",            "151=0",           "157=15",                      "159=3447.35",          "192=0",                "198=3739:20130321:50018:5",
                "223=0.0425",             "228=1",          "236=0.0291371041", "238=0",           "381=2432874.5",               "423=1",                "470=GB",               "541=20360307",
                // NoPartyIDs
                "453=6",
                "448=VCON",               "447=D",          "452=1",            "802=1",           "523=14",                      "803=4",
                "448=TFOLIO:6804469",     "447=D",          "452=12",
                "448=TFOLIO",             "447=D",          "452=11",
                "448=THINKFOLIO LTD",     "447=D",          "452=13",
                "448=SXT",                "447=D",          "452=16",
                "448=TFOLIO:6804469",     "447=D",          "452=36",
                "10=152"
            };
            string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH;

            QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport();
            msg.FromString(msgStr, true, dd, dd, null); // <-- null factory!

            Console.WriteLine(msg.ToString());

            QuickFix.FIX44.ExecutionReport.NoPartyIDsGroup partyGroup = new QuickFix.FIX44.ExecutionReport.NoPartyIDsGroup();
            msg.GetGroup(2, partyGroup);

            Assert.False(partyGroup.IsSetNoPartySubIDs());
        }
Example #3
0
        public void NestedRepeatingGroupParseGroupTest()
        {
            String data = "8=FIX.4.4\x01" + "9=309\x01" + "35=8\x01" + "49=ASX\x01" + "56=CL1_FIX44\x01" + "34=4\x01" + "52=20060324-01:05:58\x01" + ""
                + "17=X-B-WOW-1494E9A0:58BD3F9D-1109\x01" + "150=D\x01" + "39=0\x01" + "11=184271\x01" + "38=200\x01" + "198=1494E9A0:58BD3F9D\x01" + ""
                + "526=4324\x01" + "37=B-WOW-1494E9A0:58BD3F9D\x01" + "55=WOW\x01" + "54=1\x01" + "151=200\x01" + "14=0\x01" + "40=2\x01" + "44=15\x01" + "59=1\x01" + "6=0\x01" + ""
                + "453=3\x01"
                  + "448=AAA35791\x01" + "447=D\x01" + "452=3\x01" + "802=1\x01" + "523=OHAI123\x01"
                  + "448=8\x01" + "447=D\x01" + "452=4\x01"
                  + "448=FIX11\x01" + "447=D\x01" + "452=36\x01" + ""
                + "60=20060320-03:34:29\x01" + "10=169\x01" + "";
            var msg = new QuickFix.FIX44.ExecutionReport();
            var dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX44.xml");
            msg.FromString(data, false, dd, dd, _defaultMsgFactory);

            var subGrp = msg.GetGroup(1, Tags.NoPartyIDs).GetGroup(1, Tags.NoPartySubIDs);
            Assert.That(subGrp.GetString(Tags.PartySubID), Is.EqualTo("OHAI123"));
        }
Example #4
0
        public void FromString_Groups_NoFactory()
        {
            // issue 179
            var dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX44.xml");

            string[] msgFields = {
                // header
                "8=FIX.4.4","9=638", "35=8", "34=360", "49=BLPTSOX", "52=20130321-15:21:23", "56=THINKTSOX", "57=6804469", "128=ZERO",
                // non-group body fields
                "6=122.255", "11=61101189", "14=1990000", "15=GBP", "17=VCON:20130321:50018:5:12", "22=4", "31=122.255", "32=1990000",
                "37=116", "38=1990000", "39=2", "48=GB0032452392", "54=1", "55=[N/A]", "60=20130321-15:21:23", "64=20130322", "75=20130321",
                "106=UK TSY 4 1/4% 2036", "118=2436321.85", "150=F", "151=0", "157=15", "159=3447.35", "192=0", "198=3739:20130321:50018:5",
                "223=0.0425", "228=1", "236=0.0291371041", "238=0", "381=2432874.5", "423=1", "470=GB", "541=20360307",
                // NoPartyIDs
                "453=6",
                "448=VCON", "447=D", "452=1", "802=1", "523=14", "803=4",
                "448=TFOLIO:6804469", "447=D", "452=12",
                "448=TFOLIO", "447=D", "452=11",
                "448=THINKFOLIO LTD", "447=D", "452=13",
                "448=SXT", "447=D", "452=16",
                "448=TFOLIO:6804469", "447=D", "452=36",
                "10=152"
            };
            string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH;

            QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport();
            msg.FromString(msgStr, true, dd, dd, null); // <-- null factory!

            Console.WriteLine(msg.ToString());

            QuickFix.FIX44.ExecutionReport.NoPartyIDsGroup partyGroup = new QuickFix.FIX44.ExecutionReport.NoPartyIDsGroup();
            msg.GetGroup(2, partyGroup);

            Assert.False(partyGroup.IsSetNoPartySubIDs());
        }
Example #5
0
        public void ToXMLWithGroupsTest()
        {
            var dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX44.xml");

            string[] msgFields = {
                // header
                "8=FIX.4.4","9=638", "35=8", "34=360", "49=BLPTSOX", "52=20130321-15:21:23", "56=THINKTSOX", "57=6804469", "128=ZERO",
                // non-group body fields
                "6=122.255", "11=61101189", "14=1990000", "15=GBP", "17=VCON:20130321:50018:5:12", "22=4", "31=122.255", "32=1990000",
                "37=116", "38=1990000", "39=2", "48=GB0032452392", "54=1", "55=[N/A]", "60=20130321-15:21:23", "64=20130322", "75=20130321",
                "106=UK TSY 4 1/4% 2036", "118=2436321.85", "150=F", "151=0", "157=15", "159=3447.35", "192=0", "198=3739:20130321:50018:5",
                "223=0.0425", "228=1", "236=0.0291371041", "238=0", "381=2432874.5", "423=1", "470=GB", "541=20360307",
                // NoPartyIDs
                "453=6",
                "448=VCON", "447=D", "452=1", "802=1", "523=14", "803=4",
                "448=TFOLIO:6804469", "447=D", "452=12",
                "448=TFOLIO", "447=D", "452=11",
                "448=THINKFOLIO LTD", "447=D", "452=13",
                "448=SXT", "447=D", "452=16",
                "448=TFOLIO:6804469", "447=D", "452=36",
                "10=152"
            };
            string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH;

            QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport();
            msg.FromString(msgStr, true, dd, dd, null); // <-- null factory!


            string xmlDoc = msg.toXML();

            System.Diagnostics.Debug.Print(xmlDoc.ToString());

            XDocument doc = null;
            try
            {
                doc = XDocument.Parse(xmlDoc);
            }
            catch (Exception e)
            {
                Assert.Fail("Badly formed XML generated: " + e.Message);
            }


            var groups = doc.Descendants("message").Descendants("body").Elements("group")
                .Select(group =>
                    new
                    {
                        numbers = group.Descendants("field").Attributes("number"),
                        values = group.Descendants("field")
                    })

                    .ToList();
            int ct = 0;
            foreach (var elem in groups)
            {
                int number = 0;
                Group group = msg.GetGroup(++ct, 453);

                var valueEnum = elem.values.GetEnumerator();
                foreach (var numberEnum in elem.numbers)
                {
                    valueEnum.MoveNext();
                    string value = valueEnum.Current.Value;

                    if (int.TryParse(numberEnum.Value.ToString(), out number) == false)
                    {
                        Assert.Fail("should be number " + numberEnum.Value.ToString());
                    }
                    else
                    {
                        if (group.IsSetField(number))
                        {
                            string msgValue = group.GetField(number);
                            Assert.That(value, Is.EqualTo(msgValue));
                        }
                    }
                }

            }

        }
Example #6
0
        public void TestQuickFIXCompatibleGroups()
        {
            // allow QuickFIX compatible group parsing (note test MissingDelimiterField proves the reverse)

            var dd = new QuickFix.DataDictionary.DataDictionary();
            dd.Load("../../../spec/fix/FIX44.xml");

            // group 555 does not begin with 600
            
            string[] msgFields = { "8=FIX.4.4", "9=296", "35=8", "34=2", "49=XXXXX", "52=20150731-12:00:00.000", "56=CLIENT2",
                "1=C", "11=T01", "17=123", "37=ST1", "39=0", "44=10000", "54=1", "55=CAD", "60=20150731-12:00:00.000",
                "75=20150731", "109=BRK","150=0","167=F", "375=ABC", "423=0","555=1", "687=1","943=R1", "5296=1",
                "5322=ABC","5442=MST1", "5444=1", "5474=S", "5475=MAR16", "5476=PRIV1",
                "5477=PUB1", "5478=0","5479=0","5681=0","7931=0","10=43"
            };
            string msgStr = String.Join(Message.SOH, msgFields) + Message.SOH;

            QuickFix.FIX44.ExecutionReport msg = new QuickFix.FIX44.ExecutionReport();
            msg.QuickFIXCompatibleGroups = true;            
            Assert.DoesNotThrow(delegate { msg.FromString(msgStr, true, dd, dd, _defaultMsgFactory); });

            Group group = msg.GetGroup(1, 555);
            Assert.IsNotNull(group, "Group should be created");

        }
Example #7
0
        public static OrdemInfo Fix44ExecutionReport2OrdemInfo(QuickFix.FIX44.ExecutionReport er, FixSessionItem cfg)
        {
            try
            {
                OrdemInfo order     = new OrdemInfo();
                string    descricao = string.Empty;

                // order = new OrdemInfo();
                order.Account     = Convert.ToInt32(er.IsSetAccount() ? er.Account.getValue() : "0");
                order.Exchange    = cfg.Bolsa;
                order.ChannelID   = cfg.Operador;
                order.ClOrdID     = er.ClOrdID.ToString();//chaveClOrdId;
                order.OrigClOrdID = er.IsSetOrigClOrdID() ? er.OrigClOrdID.getValue() : null;
                order.ExecBroker  = "227";
                if (er.IsSetExpireDate())
                {
                    string expdate = er.ExpireDate.getValue() + "235959";
                    order.ExpireDate = DateTime.ParseExact(expdate, "yyyyMMddHHmmss", CultureInfo.InvariantCulture);
                }
                else
                {
                    order.ExpireDate = DateTime.MinValue;
                }
                order.MaxFloor    = er.IsSetMaxFloor() ? Convert.ToDouble(er.MaxFloor.getValue()) : 0;
                order.MinQty      = er.IsSetMinQty() ? Convert.ToDouble(er.MinQty.getValue()) : 0;
                order.OrderQty    = Convert.ToInt32(er.IsSetOrderQty() ? er.OrderQty.getValue() : 0);
                order.OrdType     = FixMessageUtilities.TraduzirOrdemTipo(er.OrdType.getValue());
                order.Price       = er.IsSetPrice() ? Convert.ToDouble(er.Price.getValue()) : 0;
                order.SecurityID  = er.IsSetSecurityID() ? er.SecurityID.ToString() : null;
                order.Side        = er.IsSetSide() ? (OrdemDirecaoEnum)Convert.ToInt32(er.Side.ToString()) : OrdemDirecaoEnum.NaoInformado;
                order.Symbol      = er.IsSetSymbol() ? er.Symbol.ToString() : null;
                order.TimeInForce = er.IsSetTimeInForce() ? FixMessageUtilities.deTimeInForceParaOrdemValidade(er.TimeInForce) : OrdemValidadeEnum.NaoInformado;
                //}

                order.ExchangeNumberID   = er.IsSetOrderID() ? er.OrderID.getValue() : null;
                order.OrderQtyRemmaining = Convert.ToInt32(er.IsSetLeavesQty() ? er.LeavesQty.getValue() : 0);
                order.CumQty             = Convert.ToInt32(er.IsSetCumQty() ? er.CumQty.getValue() : 0);
                order.OrdStatus          = FixMessageUtilities.TraduzirOrdemStatus(er.OrdStatus.getValue());
                order.Memo5149           = er.IsSetField(5149) ? er.GetField(5149) : String.Empty;
                order.PossDupFlag        = er.Header.IsSetField(Tags.PossDupFlag) ? er.Header.GetBoolean(Tags.PossDupFlag) : false;
                order.PossResend         = er.Header.IsSetField(Tags.PossResend) ? er.Header.GetBoolean(Tags.PossResend) : false;
                order.CompIDBolsa        = er.Header.IsSetField(Tags.SenderCompID) ? er.Header.GetString(Tags.SenderCompID) : cfg.SenderCompID;
                order.CompIDOMS          = er.Header.IsSetField(Tags.TargetCompID) ? er.Header.GetString(Tags.TargetCompID) : cfg.TargetCompID;

                switch (order.OrdStatus)
                {
                case OrdemStatusEnum.NOVA:
                    descricao          = "Ordem aberta";
                    order.RegisterTime = DateTime.Now;
                    break;

                case OrdemStatusEnum.CANCELADA:
                    descricao = "Ordem cancelada";
                    break;

                case OrdemStatusEnum.PARCIALMENTEEXECUTADA:
                    descricao = "Ordem com execucao parcial";
                    break;

                case OrdemStatusEnum.SUSPENSA:
                    descricao = "Ordem suspensa";
                    break;

                case OrdemStatusEnum.EXECUTADA:
                    descricao = "Ordem executada";
                    break;

                case OrdemStatusEnum.SUBSTITUIDA:
                    descricao = "Ordem substituida";
                    break;

                case OrdemStatusEnum.REJEITADA:
                    if (er.IsSetText())
                    {
                        descricao = er.Text.getValue();
                    }
                    break;
                }
                order.TransactTime = DateTime.Now;
                // Try get the msg seq number
                order.FixMsgSeqNum    = er.Header.IsSetField(Tags.MsgSeqNum) ? er.Header.GetInt(Tags.MsgSeqNum) : 0;
                order.ProtectionPrice = Convert.ToDecimal(er.IsSetField(35001) ? er.GetString(35001) : "0");


                // Setando informações de acompanhamento
                AcompanhamentoOrdemInfo acompanhamento = new AcompanhamentoOrdemInfo();
                acompanhamento.NumeroControleOrdem    = order.ClOrdID;
                acompanhamento.CodigoDoCliente        = order.Account;
                acompanhamento.CodigoResposta         = order.ExchangeNumberID;
                acompanhamento.CodigoTransacao        = er.IsSetExecID() ? er.ExecID.getValue() : null;
                acompanhamento.Instrumento            = order.Symbol;
                acompanhamento.SecurityID             = order.SecurityID;
                acompanhamento.CanalNegociacao        = order.ChannelID;
                acompanhamento.Direcao                = order.Side;
                acompanhamento.QuantidadeSolicitada   = order.OrderQty;
                acompanhamento.QuantidadeExecutada    = (int)er.CumQty.getValue();
                acompanhamento.QuantidadeRemanescente = (int)er.LeavesQty.getValue();
                acompanhamento.QuantidadeNegociada    = er.IsSetLastQty() ? (int)er.LastQty.getValue() : 0;
                acompanhamento.Preco           = new Decimal(order.Price);
                acompanhamento.StatusOrdem     = FixMessageUtilities.TraduzirOrdemStatus(er.OrdStatus.getValue());
                acompanhamento.DataOrdemEnvio  = order.TransactTime;
                acompanhamento.DataAtualizacao = DateTime.Now;
                acompanhamento.CodigoRejeicao  = er.IsSetOrdRejReason() ? er.OrdRejReason.ToString() : "0";
                acompanhamento.Descricao       = descricao;
                // Try get the msg seq number
                acompanhamento.FixMsgSeqNum = er.Header.IsSetField(Tags.MsgSeqNum) ? er.Header.GetInt(Tags.MsgSeqNum) : 0;
                acompanhamento.LastPx       = er.IsSetLastPx() ? (Decimal)er.LastPx.getValue() : new Decimal(order.Price);
                acompanhamento.TradeDate    = er.IsSetTradeDate() ? er.TradeDate.getValue() : DateTime.Now.ToString("yyyyMMdd");

                //BEI Fields
                //Added in 2012-Nov-13 by ATP
                acompanhamento.ExchangeOrderID          = er.IsSetField(35022) ? er.GetString(35022) : String.Empty;
                acompanhamento.ExchangeExecID           = er.IsSetField(35023) ? er.GetString(35023) : String.Empty;
                acompanhamento.LastPxInIssuedCurrency   = Convert.ToDecimal(er.IsSetField(35024) ? er.GetString(35024) : "0");
                acompanhamento.PriceInIssuedCurrency    = Convert.ToDecimal(er.IsSetField(35025) ? er.GetString(35025) : "0");
                acompanhamento.ExchangeSecondaryOrderID = er.IsSetField(35026) ? er.GetString(35026) : String.Empty;
                acompanhamento.TradeLinkID     = er.IsSetField(820) ? er.GetString(820) : String.Empty;
                acompanhamento.OrderLinkID     = er.IsSetField(5975) ? er.GetString(5975) : String.Empty;
                acompanhamento.ExchangeQuoteID = er.IsSetField(5001) ? er.GetString(5001) : String.Empty;
                acompanhamento.PossDupFlag     = er.Header.IsSetField(Tags.PossDupFlag) ? er.Header.GetBoolean(Tags.PossDupFlag) : false;
                acompanhamento.PossResend      = er.Header.IsSetField(Tags.PossResend) ? er.Header.GetBoolean(Tags.PossResend) : false;
                acompanhamento.CompIDBolsa     = er.Header.IsSetField(Tags.SenderCompID) ? er.Header.GetString(Tags.SenderCompID) : cfg.SenderCompID;
                acompanhamento.CompIDOMS       = er.Header.IsSetField(Tags.TargetCompID) ? er.Header.GetString(Tags.TargetCompID) : cfg.TargetCompID;

                if (er.IsSetNoMiscFees())
                {
                    int ocorr = er.GetInt(Tags.NoMiscFees);// noMiscFees.getValue();

                    for (uint i = 0; i < ocorr; i++)
                    {
                        EmolumentoInfo emol     = new EmolumentoInfo();
                        Group          feeGroup = er.GetGroup((int)i, Tags.NoMiscFees);
                        emol.Valor          = Convert.ToDecimal(feeGroup.IsSetField(Tags.MiscFeeAmt) ? feeGroup.GetString(Tags.MiscFeeAmt) : "0");
                        emol.BaseEmolumento = Convert.ToInt32(feeGroup.IsSetField(Tags.MiscFeeBasis) ? feeGroup.GetString(Tags.MiscFeeBasis) : "0");
                        emol.Currency       = feeGroup.GetString(Tags.MiscFeeCurr);
                        emol.Tipo           = (EmolumentoTipoEnum)feeGroup.GetInt(Tags.MiscFeeType);
                    }
                }

                // Adicionando informações de acompanhamento ao OrdemInfo
                order.Acompanhamentos.Clear();
                order.Acompanhamentos.Add(acompanhamento);

                return(order);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44ExecutionReport2OrdemInfo(): " + ex.Message, ex);
            }
            return(null);
        }
        public void OnMessage(QuickFix.FIX44.ExecutionReport m, SessionID s)
        {
            var utcNow = DateTime.UtcNow;

            var stringBuilder = new StringBuilder("***Execution report***:\r\n");

            stringBuilder.Append("================\r\n");
            for (int i = 1; i <= m.GetInt(QuickFix.Fields.Tags.NoContraBrokers); i++)
            {
                var group = new QuickFix.FIX44.ExecutionReport.NoContraBrokersGroup();
                m.GetGroup(i, group);
                stringBuilder.Append("LP:").Append(group.ContraBroker.getValue()).Append("\r\n");
            }
            stringBuilder.Append("Price:").Append(m.AvgPx.getValue()).Append("\r\n");
            stringBuilder.Append("Side:").Append(m.Side.getValue() == '1'?"Buy" :"Sell").Append("\r\n");
            stringBuilder.Append("Quantity:").Append(m.OrderQty.getValue()).Append("\r\n");

            var TimeIn        = default(DateTime);
            var TimeOut       = default(DateTime);
            var BrokerReceipt = default(DateTime);
            var BrokerExec    = default(DateTime);

            for (int i = 1; i <= m.GetInt(QuickFix.Fields.Tags.NoTrdRegTimestamps); i++)
            {
                var group = new QuickFix.FIX44.CollateralReport.NoTrdRegTimestampsGroup();
                m.GetGroup(i, group);
                switch (i)
                {
                case 1:
                    TimeIn = group.TrdRegTimestamp.getValue();
                    break;

                case 2:
                    TimeOut = group.TrdRegTimestamp.getValue();
                    break;

                case 3:
                    BrokerReceipt = group.TrdRegTimestamp.getValue();
                    break;

                case 4:
                    BrokerExec = group.TrdRegTimestamp.getValue();
                    break;
                }
            }
            var clientSentDate = this._orderClientTimestamp[m.ClOrdID.getValue()];


            stringBuilder.Append("TimeStamps:\r\n");
            stringBuilder.Append("Customer sent:").Append(clientSentDate.ToString("h:m:s.fff")).Append("\r\n");
            stringBuilder.Append("Time in:").Append(TimeIn.ToString("h:m:s.fff")).Append("\r\n");
            stringBuilder.Append("Broker receipt:").Append(BrokerReceipt.ToString("h:m:s.fff")).Append("\r\n");
            stringBuilder.Append("Broker exec:").Append(BrokerExec.ToString("h:m:s.fff")).Append("\r\n");
            stringBuilder.Append("Time out:").Append(TimeOut.ToString("h:m:s.fff")).Append("\r\n");
            stringBuilder.Append("Customer exec:").Append(utcNow.ToString("h:m:s.fff")).Append("\r\n");


            stringBuilder.Append("Customer       |  IdsRoot   |  LP\r\n").Append("\r\n");
            stringBuilder.Append("Customer sent->|            |\r\n").Append("\r\n");
            stringBuilder.Append("               |-> Time in  |\r\n").Append("\r\n");
            stringBuilder.Append("               |            |-> Broker Receipt\r\n").Append("\r\n");
            stringBuilder.Append("               |            |<- Broker exec\r\n").Append("\r\n");
            stringBuilder.Append("               |<- Time out |\r\n").Append("\r\n");
            stringBuilder.Append("Customer exec<-|            |\r\n").Append("\r\n");
            Console.WriteLine(stringBuilder.ToString());
        }
Example #9
0
        public static QuickFix.FIX42.ExecutionReport Fix44ER_2_Fix42ER(QuickFix.FIX44.ExecutionReport er44)
        {
            try
            {
                QuickFix.FIX42.ExecutionReport er42 = new QuickFix.FIX42.ExecutionReport();
                // if (er44.IsSetApplID()) er42.Set(new ApplID(er44.ApplID.getValue()));
                // if (er44.IsSetApplSeqNum()) er42.Set(new ApplSeqNum(er44.ApplSeqNum.getValue()));
                if (er44.IsSetOrderID())
                {
                    er42.Set(new OrderID(er44.OrderID.getValue()));
                }
                if (er44.IsSetSecondaryOrderID())
                {
                    er42.Set(new SecondaryOrderID(er44.SecondaryOrderID.getValue()));
                }
                // if (er44.IsSetSecondaryExecID()) er42.Set(new SecondaryExecID(er44.SecondaryExecID.getValue()));
                if (er44.IsSetClOrdID())
                {
                    er42.Set(new ClOrdID(er44.ClOrdID.getValue()));
                }
                if (er44.IsSetOrigClOrdID())
                {
                    er42.Set(new OrigClOrdID(er44.OrigClOrdID.getValue()));
                }
                //if (er44.IsSetNoPartyIDs()) er42.Set(new NoPartyIDs(er44.NoPartyIDs.getValue()));
                //if (er44.IsSetPartyID()) er42.Set(new PartyID(er44.PartyID.getValue()));
                //if (er44.IsSetPartyIDSource()) er42.Set(new PartyIDSource(er44.PartyIDSource.getValue()));
                //if (er44.IsSetPartyRole()) er42.Set(new PartyRole(er44.PartyRole.getValue()));

                // TODO[FF] - Montagem dos grupos
                if (er44.IsSetNoContraBrokers())
                {
                    er42.Set(new NoContraBrokers(er44.NoContraBrokers.getValue()));
                    int len = er44.NoContraBrokers.getValue();
                    for (int i = 1; i <= len; i++)
                    {
                        Group grp = er44.GetGroup(i, Tags.NoContraBrokers);
                        er42.AddGroup(grp);
                    }
                }

                //if (er44.IsSetContra ContraBroker()) er42.Set(new ContraBroker(er44.ContraBroker.getValue()));
                // if (er44.IsSetCrossID()) er42.Set(new CrossID(er44.CrossID.getValue()));
                if (er44.IsSetExecID())
                {
                    er42.Set(new ExecID(er44.ExecID.getValue()));
                }
                if (er44.IsSetExecRefID())
                {
                    er42.Set(new ExecRefID(er44.ExecRefID.getValue()));
                }
                if (er44.IsSetExecType())
                {
                    er42.Set(new ExecType(er44.ExecType.getValue()));
                }
                if (er44.IsSetOrdStatus())
                {
                    er42.Set(new OrdStatus(er44.OrdStatus.getValue()));
                }
                // if (er44.IsSetWorkingIndicator()) er42.Set(new WorkingIndicator(er44.WorkingIndicator.getValue()));
                //if (er44.IsSetOrdRejReason()) er42.Set(new OrdRejReason(er44.OrdRejReason.getValue()));
                if (er44.IsSetOrdRejReason())
                {
                    er42.Set(new OrdRejReason(99));                           // Will always set "99" - other
                }
                if (er44.IsSetExecRestatementReason())
                {
                    er42.Set(new ExecRestatementReason(er44.ExecRestatementReason.getValue()));
                }
                if (er44.IsSetAccount())
                {
                    er42.Set(new Account(er44.Account.getValue()));
                }
                // if (er44.IsSetAccountType()) er42.Set(new AccountType(er44.AccountType.getValue()));
                if (er44.IsSetSettlType())
                {
                    er42.Set(new SettlmntTyp(er44.SettlType.getValue()[0]));
                }
                // if (er44.IsSetDaysToSettlement()) er42.Set(new DaysToSettlement(er44.DaysToSettlement.getValue()));
                // if (er44.IsSetFixedRate()) er42.Set(new FixedRate(er44.FixedRate.getValue()));
                if (er44.IsSetSymbol())
                {
                    er42.Set(new Symbol(er44.Symbol.getValue()));
                }
                if (er44.IsSetSecurityID())
                {
                    er42.Set(new SecurityID(er44.SecurityID.getValue()));
                }
                // if (er44.IsSetSecurityIDSource()) er42.Set(new SecurityIDSource(er44.SecurityIDSource.getValue()));
                if (er44.IsSetSecurityExchange())
                {
                    er42.Set(new SecurityExchange(er44.SecurityExchange.getValue()));
                }
                if (er44.IsSetSide())
                {
                    er42.Set(new Side(er44.Side.getValue()));
                }
                if (er44.IsSetOrderQty())
                {
                    er42.Set(new OrderQty(er44.OrderQty.getValue()));
                }
                if (er44.IsSetOrdType())
                {
                    er42.Set(new OrdType(er44.OrdType.getValue()));
                }
                if (er44.IsSetPrice())
                {
                    er42.Set(new Price(er44.Price.getValue()));
                }
                if (er44.IsSetStopPx())
                {
                    er42.Set(new StopPx(er44.StopPx.getValue()));
                }
                // if (er44.IsSetProtectionPrice()) er42.Set(new ProtectionPrice(er44.ProtectionPrice.getValue()));
                if (er44.IsSetCurrency())
                {
                    er42.Set(new Currency(er44.Currency.getValue()));
                }
                if (er44.IsSetTimeInForce())
                {
                    er42.Set(new TimeInForce(er44.TimeInForce.getValue()));
                }
                if (er44.IsSetExpireDate())
                {
                    er42.Set(new ExpireDate(er44.ExpireDate.getValue()));
                }
                if (er44.IsSetLastQty())
                {
                    er42.Set(new LastShares(er44.LastQty.getValue()));
                }
                if (er44.IsSetLastPx())
                {
                    er42.Set(new LastPx(er44.LastPx.getValue()));
                }
                if (er44.IsSetLeavesQty())
                {
                    er42.Set(new LeavesQty(er44.LeavesQty.getValue()));
                }
                if (er44.IsSetCumQty())
                {
                    er42.Set(new CumQty(er44.CumQty.getValue()));
                }
                if (er44.IsSetAvgPx())
                {
                    er42.Set(new AvgPx(er44.AvgPx.getValue()));
                }
                if (er44.IsSetTradeDate())
                {
                    er42.Set(new TradeDate(er44.TradeDate.getValue()));
                }
                if (er44.IsSetTransactTime())
                {
                    er42.Set(new TransactTime(er44.TransactTime.getValue()));
                }
                // if (er44.IsSetAggressorIndicator()) er42.Set(new AggressorIndicator(er44.AggressorIndicator.getValue()));
                if (er44.IsSetMinQty())
                {
                    er42.Set(new MinQty(er44.MinQty.getValue()));
                }
                if (er44.IsSetMaxFloor())
                {
                    er42.Set(new MaxFloor(er44.MaxFloor.getValue()));
                }
                if (er44.IsSetText())
                {
                    er42.Set(new Text(er44.Text.getValue()));
                }
                if (er44.IsSetMultiLegReportingType())
                {
                    er42.Set(new MultiLegReportingType(er44.MultiLegReportingType.getValue()));
                }
                // if (er44.IsSetTotNoRelatedSym()) er42.Set(new TotNoRelatedSym(er44.TotNoRelatedSym.getValue()));
                // if (er44.IsSetNoMiscFees()) er42.Set(new NoMiscFees(er44.NoMiscFees.getValue()));
                // if (er44.IsSetMiscFeeAmt()) er42.Set(new MiscFeeAmt(er44.MiscFeeAmt.getValue()));
                // if (er44.IsSetMiscFeeCurr()) er42.Set(new MiscFeeCurr(er44.MiscFeeCurr.getValue()));
                // if (er44.IsSetMiscFeeType()) er42.Set(new MiscFeeType(er44.MiscFeeType.getValue()));
                // if (er44.IsSetMiscFeeBasis()) er42.Set(new MiscFeeBasis(er44.MiscFeeBasis.getValue()));
                // if (er44.IsSetUniqueTradeID()) er42.Set(new UniqueTradeID(er44.UniqueTradeID.getValue()));
                // if (er44.IsSetTradeLinkID()) er42.Set(new TradeLinkID(er44.TradeLinkID.getValue()));
                // if (er44.IsSetOrderLinkID()) er42.Set(new OrderLinkID(er44.OrderLinkID.getValue()));
                // if (er44.IsSetExchangeQuoteID()) er42.Set(new ExchangeQuoteID(er44.ExchangeQuoteID.getValue()));
                // if (er44.IsSetExchangeOrderID()) er42.Set(new ExchangeOrderID(er44.ExchangeOrderID.getValue()));
                // if (er44.IsSetExchangeExecID()) er42.Set(new ExchangeExecID(er44.ExchangeExecID.getValue()));
                // if (er44.IsSetLastPxInIssuedCurrency()) er42.Set(new LastPxInIssuedCurrency(er44.LastPxInIssuedCurrency.getValue()));
                // if (er44.IsSetPriceInIssuedCurrency()) er42.Set(new PriceInIssuedCurrency(er44.PriceInIssuedCurrency.getValue()));
                // if (er44.IsSetExchangeSecondaryOrderID()) er42.Set(new ExchangeSecondaryOrderID(er44.ExchangeSecondaryOrderID.getValue()));
                // if (er44.IsSetOrderCategory()) er42.Set(new OrderCategory(er44.OrderCategory.getValue()));
                if (er44.IsSetField(Tags.Memo))
                {
                    er42.SetField(new Memo(er44.GetField(Tags.Memo)));
                }

                // Validacao campo ExecTransType
                switch (er44.OrdStatus.getValue())
                {
                case OrdStatus.NEW:
                    er42.Set(new ExecTransType(ExecTransType.NEW));
                    break;

                case OrdStatus.CANCELED:
                case OrdStatus.REPLACED:     // TODO [FF] - Rever se o tratamento esta correto
                    er42.Set(new ExecTransType(ExecTransType.STATUS));
                    // er42.Set(new ExecRefID(er44.ExecRefID.getValue()));
                    break;

                case OrdStatus.REJECTED:
                case OrdStatus.FILLED:
                case OrdStatus.PARTIALLY_FILLED:
                    er42.Set(new ExecTransType(ExecTransType.STATUS));
                    er42.Set(new ExecType(er44.OrdStatus.getValue()));     // 4.2 nao aceita ExecType=F
                    break;

                case OrdStatus.EXPIRED:
                    er42.Set(new ExecTransType(ExecTransType.STATUS));
                    er42.Set(new OrdStatus(OrdStatus.DONE_FOR_DAY));
                    er42.Set(new ExecType(ExecType.DONE_FOR_DAY));
                    break;
                }
                // Validacao campo


                /*
                 * if (er44.IsSetAvgPx()) er42.Set(new AvgPx(er44.AvgPx.getValue()));
                 * if (er44.IsSetClOrdID()) er42.Set(new ClOrdID(er44.ClOrdID.getValue()));
                 * if (er44.IsSetCommission()) er42.Set(new Commission(er44.Commission.getValue()));
                 * if (er44.IsSetCommType()) er42.Set(new CommType(er44.CommType.getValue()));
                 * if (er44.IsSetCumQty()) er42.Set(new CumQty(er44.CumQty.getValue()));
                 * if (er44.IsSetCurrency()) er42.Set(new Currency(er44.Currency.getValue()));
                 * if (er44.IsSetExecID()) er42.Set(new ExecID(er44.ExecID.getValue()));
                 * if (er44.IsSetExecRefID()) er42.Set(new ExecRefID(er44.ExecRefID.getValue()));
                 *
                 * //if (er44.IsSetExecTransType()) er42.Set(new ExecTransType(er44.ExecTransType.getValue())); // TODO[FF] - Verificar o gerenciamento deste campo
                 * if (er44.IsSetExecType()) er42.Set(new ExecType(er44.ExecType.getValue()));
                 * // if (er44.IsSetIDSource()) er42.Set(new IDSource(er44.IDSource.getValue())); // TODO[FF] - Verificar o gerenciamento deste campo
                 * if (er44.IsSetLastPx()) er42.Set(new LastPx(er44.LastPx.getValue()));
                 * // if (er44.IsSetLastShares()) er42.Set(new LastShares(er44.LastShares.getValue())); // TODO[FF] - Verificar o gerenciamento deste campo
                 * if (er44.IsSetLeavesQty()) er42.Set(new LeavesQty(er44.LeavesQty.getValue()));
                 * //if (er44.IsSetNoMiscFees()) er42.Set(new NoMiscFees(er44.NoMiscFees.getValue())); // TODO[FF] - Verificar o gerenciamento deste campo por ser group
                 * //if (er44.IsSetMiscFeeAmt()) er42.Set(new MiscFeeAmt(er44.MiscFeeAmt.getValue())); // TODO[FF] - Verificar o gerenciamento deste campo por ser elemento do group
                 * if (er44.IsSetOrderID()) er42.Set(new OrderID(er44.OrderID.getValue()));
                 * if (er44.IsSetOrderQty()) er42.Set(new OrderQty(er44.OrderQty.getValue()));
                 * if (er44.IsSetOrdStatus()) er42.Set(new OrdStatus(er44.OrdStatus.getValue()));
                 * if (er44.IsSetOrdType()) er42.Set(new OrdType(er44.OrdType.getValue()));
                 * if (er44.IsSetOrigClOrdID()) er42.Set(new OrigClOrdID(er44.OrigClOrdID.getValue()));
                 * if (er44.IsSetSecurityID()) er42.Set(new SecurityID(er44.SecurityID.getValue()));
                 * if (er44.IsSetSide()) er42.Set(new Side(er44.Side.getValue()));
                 * if (er44.IsSetSymbol()) er42.Set(new Symbol(er44.Symbol.getValue()));
                 * if (er44.IsSetTransactTime()) er42.Set(new TransactTime(er44.TransactTime.getValue()));
                 * if (er44.IsSetSecurityType()) er42.Set(new SecurityType(er44.SecurityType.getValue()));
                 * if (er44.IsSetSecurityExchange()) er42.Set(new SecurityExchange(er44.SecurityExchange.getValue()));
                 */
                return(er42);
            }
            catch (Exception ex)
            {
                logger.Error("Fix44ER_2_Fix42ER(): " + ex.Message, ex);
                return(null);
            }
        }