//-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            //  'generalTerms/effectiveDate'
            //  'generalTerms/scheduledTerminationDate'
            //  'generalTerms/buyerSellerModel'
            //  'generalTerms/dateAdjustments'
            //  'generalTerms/referenceInformation'
            //  'generalTerms/indexReferenceInformation'
            //  'feeLeg/initialPayment'
            //  'feeLeg/periodicPayment'
            //  'protectionTerms/calculationAmount'
            // ignored elements:
            //  'generalTerms/additionalTerm'
            //  'generalTerms/substitution'
            //  'generalTerms/modifiedEquityDelivery'
            //  'feeLeg/periodicPayment/adjustedPaymentDates'
            //  'feeLeg/marketFixedRate'
            //  'feeLeg/paymentDelay'
            //  'feeLeg/initialPoints'
            //  'feeLeg/marketPrice'
            //  'feeLeg/quotationStyle'
            //  'protectionTerms/*'
            //  'cashSettlementTerms'
            //  'physicalSettlementTerms'
            // rejected elements:
            //  'generalTerms/basketReferenceInformation'
            //  'feeLeg/singlePayment'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);

            return(parseCds(document, tradeEl, tradeInfoBuilder));
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            // 'payment/payerPartyReference'
            // 'payment/receiverPartyReference'
            // 'payment/paymentAmount'
            // 'payment/paymentDate?'
            // ignored elements:
            // 'payment/payerAccountReference?'
            // 'payment/receiverAccountReference?'
            // 'payment/paymentType?'
            // 'payment/settlementInformation?'
            // 'payment/discountFactor?'
            // 'payment/presentValueAmount?'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);
            XmlElement       bulletEl         = tradeEl.getChild("bulletPayment");
            XmlElement       paymentEl        = bulletEl.getChild("payment");

            BulletPayment.Builder bulletBuilder = BulletPayment.builder();
            // pay/receive and counterparty
            bulletBuilder.payReceive(document.parsePayerReceiver(paymentEl, tradeInfoBuilder));
            // payment date
            bulletBuilder.date(document.parseAdjustableDate(paymentEl.getChild("paymentDate")));
            // amount
            bulletBuilder.value(document.parseCurrencyAmount(paymentEl.getChild("paymentAmount")));

            return(BulletPaymentTrade.builder().info(tradeInfoBuilder.build()).product(bulletBuilder.build()).build());
        }
Beispiel #3
0
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            // 'exchangedCurrency1/paymentAmount'
            // 'exchangedCurrency2/paymentAmount'
            // 'valueDate'
            // 'currency1ValueDate'
            // 'currency2ValueDate'
            // 'nonDeliverableSettlement?'
            // ignored elements:
            // 'dealtCurrency?'
            // 'exchangeRate'
            XmlElement fxEl = tradeEl.getChild("fxSingleLeg");
            // amounts
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);
            XmlElement       curr1El          = fxEl.getChild("exchangedCurrency1");
            XmlElement       curr2El          = fxEl.getChild("exchangedCurrency2");
            // pay/receive and counterparty
            PayReceive curr1PayReceive = document.parsePayerReceiver(curr1El, tradeInfoBuilder);
            PayReceive curr2PayReceive = document.parsePayerReceiver(curr2El, tradeInfoBuilder);

            if (curr1PayReceive == curr2PayReceive)
            {
                throw new FpmlParseException("FX single leg currencies must not have same Pay/Receive direction");
            }
            // amount
            CurrencyAmount curr1Amount = document.parseCurrencyAmount(curr1El.getChild("paymentAmount"));
            CurrencyAmount curr2Amount = document.parseCurrencyAmount(curr2El.getChild("paymentAmount"));

            if (curr1PayReceive == PayReceive.PAY)
            {
                curr1Amount = curr1Amount.negative();
                curr2Amount = curr2Amount.positive();
            }
            else
            {
                curr1Amount = curr1Amount.positive();
                curr2Amount = curr2Amount.negative();
            }
            // payment date
            LocalDate currency1Date = document.parseDate(fxEl.findChild("currency1ValueDate").orElseGet(() => fxEl.getChild("valueDate")));
            LocalDate currency2Date = document.parseDate(fxEl.findChild("currency2ValueDate").orElseGet(() => fxEl.getChild("valueDate")));
            // FxSingle or NDF
            Optional <XmlElement> ndfEl = fxEl.findChild("nonDeliverableSettlement");

            if (!ndfEl.Present)
            {
                return(FxSingleTrade.builder().info(tradeInfoBuilder.build()).product(FxSingle.of(Payment.of(curr1Amount, currency1Date), Payment.of(curr2Amount, currency2Date))).build());
            }
            if (!currency1Date.Equals(currency2Date))
            {
                throw new FpmlParseException("FxNdf only supports a single payment date");
            }
            return(parseNdf(document, fxEl, ndfEl.get(), curr1Amount, curr2Amount, currency1Date, tradeInfoBuilder));
        }
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            // 'nearLeg'
            // 'farLeg'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);
            XmlElement       fxEl             = tradeEl.getChild("fxSwap");
            FxSingle         nearLeg          = parseLeg(fxEl.getChild("nearLeg"), document, tradeInfoBuilder);
            FxSingle         farLeg           = parseLeg(fxEl.getChild("farLeg"), document, tradeInfoBuilder);

            return(FxSwapTrade.builder().info(tradeInfoBuilder.build()).product(FxSwap.of(nearLeg, farLeg)).build());
        }
Beispiel #5
0
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            //  'swaption'
            //  'swaption/buyerPartyReference'
            //  'swaption/sellerPartyReference'
            //  'swaption/premium/payerPartyReference'
            //  'swaption/premium/receiverPartyReference'
            //  'swaption/premium/paymentAmount'
            //  'swaption/premium/paymentDate'
            //  'swaption/europeanExercise'
            //  'swaption/europeanExercise/expirationDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate/unadjustedDate'
            //  'swaption/europeanExercise/expirationDate/adjustableDate/dateAdjustments'
            //  'swaption/europeanExercise/expirationTime
            //  'swaption/swap'
            // ignored elements:
            //  'Product.model?'
            //  'swaption/calculationAgent'
            //  'swaption/assetClass'
            //  'swaption/primaryAssestClass'
            //  'swaption/productId'
            //  'swaption/productType'
            //  'swaption/secondaryAssetClass'
            //  'swaption/sellerAccountReference'
            //  'swaption/sellerPartyReference'
            //  'swaption/swaptionAdjustedDates'
            //  'swaption/swaptionStraddle'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);

            XmlElement swaptionEl         = tradeEl.getChild("swaption");
            XmlElement europeanExerciseEl = swaptionEl.getChild("europeanExercise");
            XmlElement expirationTimeEl   = europeanExerciseEl.getChild("expirationTime");

            // Parse the premium, expiry date, expiry time and expiry zone, longShort and swaption settlement.
            AdjustablePayment  premium            = parsePremium(swaptionEl, document, tradeInfoBuilder);
            AdjustableDate     expiryDate         = parseExpiryDate(europeanExerciseEl, document);
            LocalTime          expiryTime         = parseExpiryTime(expirationTimeEl, document);
            ZoneId             expiryZone         = parseExpiryZone(expirationTimeEl, document);
            LongShort          longShort          = parseLongShort(swaptionEl, document, tradeInfoBuilder);
            SwaptionSettlement swaptionSettlement = parseSettlement(swaptionEl, document);

            //Re use the Swap FpML parser to parse the underlying swap on this swaption.
            SwapFpmlParserPlugin swapParser = SwapFpmlParserPlugin.INSTANCE;
            Swap swap = swapParser.parseSwap(document, swaptionEl, tradeInfoBuilder);

            Swaption swaption = Swaption.builder().expiryDate(expiryDate).expiryZone(expiryZone).expiryTime(expiryTime).longShort(longShort).swaptionSettlement(swaptionSettlement).underlying(swap).build();

            return(SwaptionTrade.builder().info(tradeInfoBuilder.build()).product(swaption).premium(premium).build());
        }
Beispiel #6
0
        //-------------------------------------------------------------------------
        public Trade parseTrade(FpmlDocument document, XmlElement tradeEl)
        {
            // supported elements:
            // 'payerPartyReference'
            // 'receiverPartyReference'
            // 'startDate'
            // 'maturityDate'
            // 'principal'
            // 'fixedRate'
            // 'dayCountFraction'
            // ignored elements:
            // 'payerAccountReference?'
            // 'receiverAccountReference?'
            // 'interest?'
            // rejected elements:
            // 'features?'
            // 'payment*'
            TradeInfoBuilder tradeInfoBuilder = document.parseTradeInfo(tradeEl);
            XmlElement       termEl           = tradeEl.getChild("termDeposit");

            document.validateNotPresent(termEl, "features");
            document.validateNotPresent(termEl, "payment");
            TermDeposit.Builder termBuilder = TermDeposit.builder();
            // pay/receive and counterparty
            PayReceive payReceive = document.parsePayerReceiver(termEl, tradeInfoBuilder);

            termBuilder.buySell(BuySell.ofBuy(payReceive.Pay));
            // start date
            termBuilder.startDate(document.parseDate(termEl.getChild("startDate")));
            // maturity date
            termBuilder.endDate(document.parseDate(termEl.getChild("maturityDate")));
            // principal
            CurrencyAmount principal = document.parseCurrencyAmount(termEl.getChild("principal"));

            termBuilder.currency(principal.Currency);
            termBuilder.notional(principal.Amount);
            // fixed rate
            termBuilder.rate(document.parseDecimal(termEl.getChild("fixedRate")));
            // day count
            termBuilder.dayCount(document.parseDayCountFraction(termEl.getChild("dayCountFraction")));

            return(TermDepositTrade.builder().info(tradeInfoBuilder.build()).product(termBuilder.build()).build());
        }