public virtual void test_inflation_fixed()
        {
            BusinessDayAdjustment  bda              = BusinessDayAdjustment.of(FOLLOWING, GBLO);
            PeriodicSchedule       accrualSchedule  = PeriodicSchedule.builder().startDate(DATE_14_06_09).endDate(DATE_19_06_09).frequency(P12M).businessDayAdjustment(bda).build();
            PaymentSchedule        paymentSchedule  = PaymentSchedule.builder().paymentFrequency(Frequency.ofYears(5)).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).compoundingMethod(STRAIGHT).build();
            FixedRateCalculation   rateCalc         = FixedRateCalculation.builder().rate(ValueSchedule.of(0.05)).dayCount(ONE_ONE).build();
            NotionalSchedule       notionalSchedule = NotionalSchedule.of(GBP, 1000d);
            RateCalculationSwapLeg test             = RateCalculationSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).notionalSchedule(notionalSchedule).calculation(rateCalc).build();

            assertEquals(test.StartDate, AdjustableDate.of(DATE_14_06_09, bda));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_19_06_09, bda));
            assertEquals(test.Currency, GBP);
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.AccrualSchedule, accrualSchedule);
            assertEquals(test.PaymentSchedule, paymentSchedule);
            assertEquals(test.NotionalSchedule, notionalSchedule);
            assertEquals(test.Calculation, rateCalc);
            RateAccrualPeriod rap0       = RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09, REF_DATA)).endDate(bda.adjust(DATE_14_06_09.plusYears(1), REF_DATA)).unadjustedStartDate(DATE_14_06_09).unadjustedEndDate(DATE_14_06_09.plusYears(1)).yearFraction(1.0).rateComputation(FixedRateComputation.of(0.05)).build();
            RateAccrualPeriod rap1       = RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09.plusYears(1), REF_DATA)).endDate(bda.adjust(DATE_14_06_09.plusYears(2), REF_DATA)).unadjustedStartDate(DATE_14_06_09.plusYears(1)).unadjustedEndDate(DATE_14_06_09.plusYears(2)).yearFraction(1.0).rateComputation(FixedRateComputation.of(0.05)).build();
            RateAccrualPeriod rap2       = RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09.plusYears(2), REF_DATA)).endDate(bda.adjust(DATE_14_06_09.plusYears(3), REF_DATA)).unadjustedStartDate(DATE_14_06_09.plusYears(2)).unadjustedEndDate(DATE_14_06_09.plusYears(3)).yearFraction(1.0).rateComputation(FixedRateComputation.of(0.05)).build();
            RateAccrualPeriod rap3       = RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09.plusYears(3), REF_DATA)).endDate(bda.adjust(DATE_14_06_09.plusYears(4), REF_DATA)).unadjustedStartDate(DATE_14_06_09.plusYears(3)).unadjustedEndDate(DATE_14_06_09.plusYears(4)).yearFraction(1.0).rateComputation(FixedRateComputation.of(0.05)).build();
            RateAccrualPeriod rap4       = RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09.plusYears(4), REF_DATA)).endDate(bda.adjust(DATE_19_06_09, REF_DATA)).unadjustedStartDate(DATE_14_06_09.plusYears(4)).unadjustedEndDate(DATE_19_06_09).yearFraction(1.0).rateComputation(FixedRateComputation.of(0.05)).build();
            RatePaymentPeriod rpp        = RatePaymentPeriod.builder().paymentDate(DaysAdjustment.ofBusinessDays(2, GBLO).adjust(bda.adjust(DATE_19_06_09, REF_DATA), REF_DATA)).accrualPeriods(rap0, rap1, rap2, rap3, rap4).compoundingMethod(STRAIGHT).dayCount(ONE_ONE).currency(GBP).notional(1000d).build();
            ResolvedSwapLeg   expected   = ResolvedSwapLeg.builder().paymentPeriods(rpp).payReceive(RECEIVE).type(SwapLegType.FIXED).build();
            ResolvedSwapLeg   testExpand = test.resolve(REF_DATA);

            assertEquals(testExpand, expected);
        }
        public virtual void test_inflation_interpolated()
        {
            BusinessDayAdjustment    bda              = BusinessDayAdjustment.of(FOLLOWING, GBLO);
            PeriodicSchedule         accrualSchedule  = PeriodicSchedule.builder().startDate(DATE_14_06_09).endDate(DATE_19_06_09).frequency(Frequency.ofYears(5)).businessDayAdjustment(bda).build();
            PaymentSchedule          paymentSchedule  = PaymentSchedule.builder().paymentFrequency(Frequency.ofYears(5)).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            InflationRateCalculation rateCalc         = InflationRateCalculation.builder().index(GB_RPI).indexCalculationMethod(INTERPOLATED).lag(Period.ofMonths(3)).build();
            NotionalSchedule         notionalSchedule = NotionalSchedule.of(GBP, 1000d);
            RateCalculationSwapLeg   test             = RateCalculationSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).notionalSchedule(notionalSchedule).calculation(rateCalc).build();

            assertEquals(test.StartDate, AdjustableDate.of(DATE_14_06_09, bda));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_19_06_09, bda));
            assertEquals(test.Currency, GBP);
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.AccrualSchedule, accrualSchedule);
            assertEquals(test.PaymentSchedule, paymentSchedule);
            assertEquals(test.NotionalSchedule, notionalSchedule);
            assertEquals(test.Calculation, rateCalc);

            double            weight     = 1.0 - 9.0 / 30.0;
            RatePaymentPeriod rpp0       = RatePaymentPeriod.builder().paymentDate(DaysAdjustment.ofBusinessDays(2, GBLO).adjust(bda.adjust(DATE_19_06_09, REF_DATA), REF_DATA)).accrualPeriods(RateAccrualPeriod.builder().startDate(bda.adjust(DATE_14_06_09, REF_DATA)).endDate(bda.adjust(DATE_19_06_09, REF_DATA)).unadjustedStartDate(DATE_14_06_09).unadjustedEndDate(DATE_19_06_09).yearFraction(1.0).rateComputation(InflationInterpolatedRateComputation.of(GB_RPI, YearMonth.from(bda.adjust(DATE_14_06_09, REF_DATA)).minusMonths(3), YearMonth.from(bda.adjust(DATE_19_06_09, REF_DATA)).minusMonths(3), weight)).build()).dayCount(ONE_ONE).currency(GBP).notional(1000d).build();
            ResolvedSwapLeg   expected   = ResolvedSwapLeg.builder().paymentPeriods(rpp0).payReceive(RECEIVE).type(SwapLegType.INFLATION).build();
            ResolvedSwapLeg   testExpand = test.resolve(REF_DATA);

            assertEquals(testExpand, expected);
        }
示例#3
0
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            BulletPayment test = BulletPayment.builder().payReceive(PayReceive.PAY).value(GBP_P1000).date(AdjustableDate.of(DATE_2015_06_30)).build();

            assertEquals(test.PayReceive, PayReceive.PAY);
            assertEquals(test.Value, GBP_P1000);
            assertEquals(test.Date, AdjustableDate.of(DATE_2015_06_30));
            assertEquals(test.Currency, GBP);
            assertEquals(test.CrossCurrency, false);
            assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(GBP));
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP));
        }
        public virtual void test_builder_defaults()
        {
            RatePeriodSwapLeg test = RatePeriodSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1).build();

            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.StartDate, AdjustableDate.of(DATE_2014_06_30));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_2014_09_30));
            assertEquals(test.Currency, GBP);
            assertEquals(test.PaymentPeriods, ImmutableList.of(RPP1));
            assertEquals(test.PaymentEvents, ImmutableList.of());
            assertEquals(test.InitialExchange, false);
            assertEquals(test.IntermediateExchange, false);
            assertEquals(test.FinalExchange, false);
            assertEquals(test.PaymentBusinessDayAdjustment, BusinessDayAdjustment.NONE);
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            RatePeriodSwapLeg test = RatePeriodSwapLeg.builder().type(IBOR).payReceive(RECEIVE).paymentPeriods(RPP1).initialExchange(true).intermediateExchange(true).finalExchange(true).paymentEvents(NOTIONAL_EXCHANGE).paymentBusinessDayAdjustment(FOLLOWING_GBLO).build();

            assertEquals(test.Type, IBOR);
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.StartDate, AdjustableDate.of(DATE_2014_06_30));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_2014_09_30));
            assertEquals(test.Currency, GBP);
            assertEquals(test.PaymentPeriods, ImmutableList.of(RPP1));
            assertEquals(test.PaymentEvents, ImmutableList.of(NOTIONAL_EXCHANGE));
            assertEquals(test.InitialExchange, true);
            assertEquals(test.IntermediateExchange, true);
            assertEquals(test.FinalExchange, true);
            assertEquals(test.PaymentBusinessDayAdjustment, FOLLOWING_GBLO);
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            BusinessDayAdjustment bda             = BusinessDayAdjustment.of(FOLLOWING, GBLO);
            PeriodicSchedule      accrualSchedule = PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(bda).build();
            PaymentSchedule       paymentSchedule = PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            ValueSchedule         amountSchedule  = ValueSchedule.of(123d);
            KnownAmountSwapLeg    test            = KnownAmountSwapLeg.builder().payReceive(PAY).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).amount(amountSchedule).currency(GBP).build();

            assertEquals(test.PayReceive, PAY);
            assertEquals(test.StartDate, AdjustableDate.of(DATE_01_05, bda));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_04_05, bda));
            assertEquals(test.AccrualSchedule, accrualSchedule);
            assertEquals(test.PaymentSchedule, paymentSchedule);
            assertEquals(test.Amount, amountSchedule);
            assertEquals(test.Currency, GBP);
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP));
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            BusinessDayAdjustment  bda              = BusinessDayAdjustment.of(FOLLOWING, GBLO);
            PeriodicSchedule       accrualSchedule  = PeriodicSchedule.builder().startDate(DATE_01_05).endDate(DATE_04_05).frequency(P1M).businessDayAdjustment(bda).build();
            PaymentSchedule        paymentSchedule  = PaymentSchedule.builder().paymentFrequency(P1M).paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            FixedRateCalculation   rateCalc         = FixedRateCalculation.builder().dayCount(DayCounts.ACT_365F).rate(ValueSchedule.of(0.025d)).build();
            NotionalSchedule       notionalSchedule = NotionalSchedule.of(GBP, 1000d);
            RateCalculationSwapLeg test             = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(accrualSchedule).paymentSchedule(paymentSchedule).notionalSchedule(notionalSchedule).calculation(rateCalc).build();

            assertEquals(test.StartDate, AdjustableDate.of(DATE_01_05, bda));
            assertEquals(test.EndDate, AdjustableDate.of(DATE_04_05, bda));
            assertEquals(test.Currency, GBP);
            assertEquals(test.PayReceive, PAY);
            assertEquals(test.AccrualSchedule, accrualSchedule);
            assertEquals(test.PaymentSchedule, paymentSchedule);
            assertEquals(test.NotionalSchedule, notionalSchedule);
            assertEquals(test.Calculation, rateCalc);
        }
        public virtual void test_builder_NZD()
        {
            ImmutableIborIndex dummyIndex = ImmutableIborIndex.builder().name("NZD-INDEX-3M").currency(NZD).dayCount(ACT_360).fixingDateOffset(MINUS_TWO_DAYS).effectiveDateOffset(PLUS_TWO_DAYS).maturityDateOffset(TenorAdjustment.ofLastDay(TENOR_3M, BDA_MOD_FOLLOW)).fixingCalendar(SAT_SUN).fixingTime(LocalTime.NOON).fixingZone(ZoneId.of("NZ")).build();
            Fra test = Fra.builder().buySell(BUY).notional(NOTIONAL_1M).startDate(date(2015, 6, 15)).endDate(date(2015, 9, 15)).paymentDate(AdjustableDate.of(date(2015, 6, 16))).fixedRate(FIXED_RATE).index(dummyIndex).fixingDateOffset(MINUS_TWO_DAYS).build();

            assertEquals(test.BuySell, BUY);
            assertEquals(test.Currency, NZD);     // defaulted
            assertEquals(test.Notional, NOTIONAL_1M, 0d);
            assertEquals(test.StartDate, date(2015, 6, 15));
            assertEquals(test.EndDate, date(2015, 9, 15));
            assertEquals(test.BusinessDayAdjustment, null);
            assertEquals(test.PaymentDate, AdjustableDate.of(date(2015, 6, 16)));
            assertEquals(test.FixedRate, FIXED_RATE, 0d);
            assertEquals(test.Index, dummyIndex);
            assertEquals(test.IndexInterpolated, null);
            assertEquals(test.FixingDateOffset, MINUS_TWO_DAYS);
            assertEquals(test.DayCount, ACT_360);     // defaulted
            assertEquals(test.Discounting, AFMA);     // defaulted
        }
        //-------------------------------------------------------------------------
        public virtual void test_builder()
        {
            Fra test = sut();

            assertEquals(test.BuySell, BUY);
            assertEquals(test.Currency, GBP);     // defaulted
            assertEquals(test.Notional, NOTIONAL_1M, 0d);
            assertEquals(test.StartDate, date(2015, 6, 15));
            assertEquals(test.EndDate, date(2015, 9, 15));
            assertEquals(test.BusinessDayAdjustment, null);
            assertEquals(test.PaymentDate, AdjustableDate.of(date(2015, 6, 15)));
            assertEquals(test.FixedRate, FIXED_RATE, 0d);
            assertEquals(test.Index, GBP_LIBOR_3M);
            assertEquals(test.IndexInterpolated, null);
            assertEquals(test.FixingDateOffset, GBP_LIBOR_3M.FixingDateOffset); // defaulted
            assertEquals(test.DayCount, ACT_365F);                              // defaulted
            assertEquals(test.Discounting, ISDA);                               // defaulted
            assertEquals(test.CrossCurrency, false);
            assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(GBP));
            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP));
        }
 public virtual void test_builder_expiryAfterStart()
 {
     assertThrowsIllegalArg(() => Swaption.builder().expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 17), ADJUSTMENT)).expiryTime(EXPIRY_TIME).expiryZone(ZONE).longShort(LONG).swaptionSettlement(PHYSICAL_SETTLE).underlying(SWAP).build());
 }
        public virtual void test_toTrade_dates_paymentOffset()
        {
            FraConvention @base       = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build();
            LocalDate     tradeDate   = LocalDate.of(2015, 5, 5);
            LocalDate     startDate   = date(2015, 8, 5);
            LocalDate     endDate     = date(2015, 11, 5);
            LocalDate     paymentDate = date(2015, 8, 7);
            FraTrade      test        = @base.toTrade(tradeDate, startDate, endDate, paymentDate, BUY, NOTIONAL_2M, 0.25d);
            Fra           expected    = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(paymentDate, PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
        public virtual void test_createTrade_periods_adjust_payOffset()
        {
            FraConvention @base     = ImmutableFraConvention.builder().index(GBP_LIBOR_3M).spotDateOffset(NEXT_SAME_BUS_DAY).paymentDateOffset(PLUS_TWO_DAYS).build();
            LocalDate     tradeDate = LocalDate.of(2016, 8, 11);
            FraTrade      test      = @base.createTrade(tradeDate, Period.ofMonths(1), Period.ofMonths(4), BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Fra           expected  = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2016, 9, 12)).endDate(date(2016, 12, 12)).paymentDate(AdjustableDate.of(date(2016, 9, 14), PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
示例#13
0
        public virtual void formatForCsv()
        {
            AdjustableDate date = AdjustableDate.of(date(2016, 6, 30), BusinessDayAdjustment.of(MODIFIED_FOLLOWING, SAT_SUN));

            assertThat(AdjustableDateValueFormatter.INSTANCE.formatForCsv(date)).isEqualTo("2016-06-30");
        }
示例#14
0
 internal static Fra sut2()
 {
     return(Fra.builder().buySell(SELL).currency(USD).notional(NOTIONAL_2M).startDate(date(2015, 6, 16)).endDate(date(2015, 8, 17)).businessDayAdjustment(BDA_MOD_FOLLOW).paymentDate(AdjustableDate.of(date(2015, 6, 17))).dayCount(ACT_360).fixedRate(0.30d).index(GBP_LIBOR_2M).indexInterpolated(GBP_LIBOR_3M).fixingDateOffset(MINUS_FIVE_DAYS).discounting(FraDiscountingMethod.NONE).build());
 }
示例#15
0
        //-------------------------------------------------------------------------
        public virtual void test_resolve_Ibor()
        {
            Fra         fra  = Fra.builder().buySell(BUY).notional(NOTIONAL_1M).startDate(date(2015, 6, 15)).endDate(date(2015, 9, 15)).paymentDate(AdjustableDate.of(date(2015, 6, 20), BDA_MOD_FOLLOW)).fixedRate(FIXED_RATE).index(GBP_LIBOR_3M).fixingDateOffset(MINUS_TWO_DAYS).build();
            ResolvedFra test = fra.resolve(REF_DATA);

            assertEquals(test.Currency, GBP);
            assertEquals(test.Notional, NOTIONAL_1M, 0d);
            assertEquals(test.StartDate, date(2015, 6, 15));
            assertEquals(test.EndDate, date(2015, 9, 15));
            assertEquals(test.PaymentDate, date(2015, 6, 22));
            assertEquals(test.FixedRate, FIXED_RATE, 0d);
            assertEquals(test.FloatingRate, IborRateComputation.of(GBP_LIBOR_3M, date(2015, 6, 11), REF_DATA));
            assertEquals(test.YearFraction, ACT_365F.yearFraction(date(2015, 6, 15), date(2015, 9, 15)), 0d);
            assertEquals(test.Discounting, ISDA);
        }
        // parses the CDS
        internal Trade parseCds(FpmlDocument document, XmlElement tradeEl, TradeInfoBuilder tradeInfoBuilder)
        {
            XmlElement cdsEl          = tradeEl.getChild("creditDefaultSwap");
            XmlElement generalTermsEl = cdsEl.getChild("generalTerms");
            XmlElement feeLegEl       = cdsEl.getChild("feeLeg");

            document.validateNotPresent(generalTermsEl, "basketReferenceInformation");
            document.validateNotPresent(feeLegEl, "singlePayment");
            BuySell buySell = document.parseBuyerSeller(generalTermsEl, tradeInfoBuilder);

            // effective and termination date are optional in FpML but mandatory for Strata
            AdjustableDate        effectiveDate   = document.parseAdjustableDate(generalTermsEl.getChild("effectiveDate"));
            AdjustableDate        terminationDate = document.parseAdjustableDate(generalTermsEl.getChild("scheduledTerminationDate"));
            BusinessDayAdjustment bda             = generalTermsEl.findChild("dateAdjustments").map(el => document.parseBusinessDayAdjustments(el)).orElse(BusinessDayAdjustment.NONE);

            PeriodicSchedule.Builder scheduleBuilder = PeriodicSchedule.builder().startDate(effectiveDate.Unadjusted).startDateBusinessDayAdjustment(effectiveDate.Adjustment).endDate(terminationDate.Unadjusted).endDateBusinessDayAdjustment(terminationDate.Adjustment).businessDayAdjustment(bda);

            // an upfront fee
            Optional <XmlElement> initialPaymentOptEl = feeLegEl.findChild("initialPayment");
            AdjustablePayment     upfrontFee          = null;

            if (initialPaymentOptEl.Present)
            {
                XmlElement     initialPaymentEl = initialPaymentOptEl.get();
                PayReceive     payRec           = document.parsePayerReceiver(initialPaymentEl, tradeInfoBuilder);
                CurrencyAmount amount           = document.parseCurrencyAmount(initialPaymentEl.getChild("paymentAmount"));
                LocalDate      date             = initialPaymentEl.findChild("adjustablePaymentDate").map(el => document.parseDate(el)).orElse(effectiveDate.Unadjusted);
                AdjustableDate adjDate          = AdjustableDate.of(date, bda);
                upfrontFee = payRec.Pay ? AdjustablePayment.ofPay(amount, adjDate) : AdjustablePayment.ofReceive(amount, adjDate);
            }

            // we require a periodicPayment and fixedAmountCalculation
            XmlElement periodicPaymentEl = feeLegEl.getChild("periodicPayment");

            scheduleBuilder.frequency(periodicPaymentEl.findChild("paymentFrequency").map(el => document.parseFrequency(el)).orElse(Frequency.P3M));
            periodicPaymentEl.findChild("firstPaymentDate").ifPresent(el => scheduleBuilder.firstRegularStartDate(document.parseDate(el)));
            periodicPaymentEl.findChild("firstPeriodStartDate").ifPresent(el => scheduleBuilder.overrideStartDate(AdjustableDate.of(document.parseDate(el))));
            periodicPaymentEl.findChild("lastRegularPaymentDate").ifPresent(el => scheduleBuilder.lastRegularEndDate(document.parseDate(el)));
            scheduleBuilder.rollConvention(periodicPaymentEl.findChild("rollConvention").map(el => document.convertRollConvention(el.Content)).orElse(null));
            XmlElement fixedAmountCalcEl = periodicPaymentEl.getChild("fixedAmountCalculation");
            double     fixedRate         = document.parseDecimal(fixedAmountCalcEl.getChild("fixedRate"));
            DayCount   dayCount          = fixedAmountCalcEl.findChild("dayCountFraction").map(el => document.parseDayCountFraction(el)).orElse(DayCounts.ACT_360);

            // handle a single protectionTerms element
            XmlElement     protectionTermEl = cdsEl.getChild("protectionTerms");
            CurrencyAmount notional         = document.parseCurrencyAmount(protectionTermEl.getChild("calculationAmount"));

            // single name CDS
            Optional <XmlElement> singleOptEl = generalTermsEl.findChild("referenceInformation");

            if (singleOptEl.Present)
            {
                // we require a single entityId
                XmlElement referenceEntityEl = singleOptEl.get().getChild("referenceEntity");
                XmlElement entityIdEl        = referenceEntityEl.getChild("entityId");
                string     scheme            = entityIdEl.findAttribute("entityIdScheme").orElse("http://www.fpml.org/coding-scheme/external/entity-id-RED-1-0");
                string     value             = entityIdEl.Content;
                StandardId entityId          = StandardId.of(scheme, value);
                Cds        cds = Cds.builder().buySell(buySell).legalEntityId(entityId).currency(notional.Currency).notional(notional.Amount).paymentSchedule(scheduleBuilder.build()).fixedRate(fixedRate).dayCount(dayCount).build();
                return(CdsTrade.builder().info(tradeInfoBuilder.build()).product(cds).upfrontFee(upfrontFee).build());
            }

            // CDS index
            Optional <XmlElement> indexOptEl = generalTermsEl.findChild("indexReferenceInformation");

            if (indexOptEl.Present)
            {
                string   indexName = indexOptEl.get().getChild("indexName").Content;
                CdsIndex cdsIndex  = CdsIndex.builder().buySell(buySell).cdsIndexId(StandardId.of("CDX-Name", indexName)).currency(notional.Currency).notional(notional.Amount).paymentSchedule(scheduleBuilder.build()).fixedRate(fixedRate).dayCount(dayCount).build();
                return(CdsIndexTrade.builder().info(tradeInfoBuilder.build()).product(cdsIndex).upfrontFee(upfrontFee).build());
            }

            // unknown type
            throw new FpmlParseException("FpML CDS must be single name or index");
        }
示例#17
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BulletPayment test = BulletPayment.builder().payReceive(PayReceive.PAY).value(GBP_P1000).date(AdjustableDate.of(DATE_2015_06_30)).build();

            coverImmutableBean(test);
            BulletPayment test2 = BulletPayment.builder().payReceive(PayReceive.RECEIVE).value(USD_P1600).date(AdjustableDate.of(DATE_2015_06_29)).build();

            coverBeanEquals(test, test2);
        }
示例#18
0
 public virtual void test_builder_notNegative()
 {
     assertThrowsIllegalArg(() => BulletPayment.builder().payReceive(PayReceive.PAY).value(GBP_M1000).date(AdjustableDate.of(DATE_2015_06_30)).build());
 }
 internal static Swaption sut2()
 {
     return(Swaption.builder().expiryDate(AdjustableDate.of(LocalDate.of(2014, 6, 10), ADJUSTMENT)).expiryTime(LocalTime.of(14, 0)).expiryZone(ZoneId.of("GMT")).longShort(SHORT).swaptionSettlement(CASH_SETTLE).underlying(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M.createTrade(LocalDate.of(2014, 6, 10), Tenor.TENOR_10Y, BuySell.BUY, 1d, FIXED_RATE, REF_DATA).Product).build());
 }
示例#20
0
        public virtual void test_resolve_receive()
        {
            BulletPayment         test     = BulletPayment.builder().payReceive(PayReceive.RECEIVE).value(GBP_P1000).date(AdjustableDate.of(DATE_2015_06_30)).build();
            ResolvedBulletPayment expected = ResolvedBulletPayment.of(Payment.of(GBP_P1000, DATE_2015_06_30));

            assertEquals(test.resolve(REF_DATA), expected);
        }
        public virtual void test_createTrade_paymentOffset()
        {
            FraConvention convention = ((ImmutableFraConvention)FRA_GBP_LIBOR_3M).toBuilder().paymentDateOffset(PLUS_TWO_DAYS).build();
            FraTemplate   @base      = FraTemplate.of(Period.ofMonths(3), Period.ofMonths(6), convention);
            LocalDate     tradeDate  = LocalDate.of(2015, 5, 4); // trade date is a holiday!
            FraTrade      test       = @base.createTrade(tradeDate, BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Fra           expected   = Fra.builder().buySell(BUY).notional(NOTIONAL_2M).startDate(date(2015, 8, 5)).endDate(date(2015, 11, 5)).paymentDate(AdjustableDate.of(date(2015, 8, 7), PLUS_TWO_DAYS.Adjustment)).fixedRate(0.25d).index(GBP_LIBOR_3M).build();

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
示例#22
0
        public virtual void test_serialization()
        {
            BulletPayment test = BulletPayment.builder().payReceive(PayReceive.PAY).value(GBP_P1000).date(AdjustableDate.of(DATE_2015_06_30)).build();

            assertSerialization(test);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ResolvedTradeParameterMetadata test1 = ResolvedTradeParameterMetadata.of(TRADE, "Label");

            coverImmutableBean(test1);
            ResolvedTrade trade = ResolvedBulletPaymentTrade.of(TradeInfo.empty(), BulletPayment.builder().date(AdjustableDate.of(LocalDate.of(2017, 3, 3))).value(CurrencyAmount.of(Currency.USD, 100d)).payReceive(PayReceive.PAY).build().resolve(REF_DATA));
            ResolvedTradeParameterMetadata test2 = ResolvedTradeParameterMetadata.builder().trade(trade).label("Label2").build();

            coverBeanEquals(test1, test2);
        }