Ejemplo n.º 1
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);
            }
        }