Example #1
0
        //-------------------------------------------------------------------------
        public PortfolioItemSummary summarize()
        {
            // 5Y USD 2mm Rec USD-LIBOR-6M Cap 1% / Pay Premium : 21Jan17-21Jan22
            StringBuilder   buf     = new StringBuilder(96);
            IborCapFloorLeg mainLeg = product.CapFloorLeg;

            buf.Append(SummarizerUtils.datePeriod(mainLeg.StartDate.Unadjusted, mainLeg.EndDate.Unadjusted));
            buf.Append(' ');
            buf.Append(SummarizerUtils.amount(mainLeg.Currency, mainLeg.Notional.InitialValue));
            buf.Append(' ');
            if (mainLeg.PayReceive.Receive)
            {
                buf.Append("Rec ");
                summarizeMainLeg(mainLeg, buf);
                buf.Append(Premium.Present ? " / Pay Premium" : (product.PayLeg.Present ? " /  Pay Periodic" : ""));
            }
            else
            {
                buf.Append(Premium.Present ? "Rec Premium / Pay " : (product.PayLeg.Present ? "Rec Periodic / Pay " : ""));
                summarizeMainLeg(mainLeg, buf);
            }
            buf.Append(" : ");
            buf.Append(SummarizerUtils.dateRange(mainLeg.StartDate.Unadjusted, mainLeg.EndDate.Unadjusted));
            return(SummarizerUtils.summary(this, ProductType.IBOR_CAP_FLOOR, buf.ToString(), mainLeg.Currency));
        }
 private IborCapFloor(IborCapFloorLeg capFloorLeg, SwapLeg payLeg)
 {
     JodaBeanUtils.notNull(capFloorLeg, "capFloorLeg");
     this.capFloorLeg = capFloorLeg;
     this.payLeg      = payLeg;
     validate();
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloorLeg test1 = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            coverImmutableBean(test1);
            IborCapFloorLeg test2 = IborCapFloorLeg.builder().calculation(IborRateCalculation.of(GBP_LIBOR_6M)).capSchedule(CAP).notional(ValueSchedule.of(1000)).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(Frequency.P6M).businessDayAdjustment(BUSS_ADJ).build()).payReceive(PAY).build();

            coverBeanEquals(test1, test2);
        }
 public virtual void test_builder_fail()
 {
     // cap and floor present
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build());
     // cap and floor missing
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).notional(NOTIONAL).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(FREQUENCY).businessDayAdjustment(BUSS_ADJ).build()).payReceive(RECEIVE).build());
     // stub type
     assertThrowsIllegalArg(() => IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(PeriodicSchedule.builder().startDate(START).endDate(END).frequency(FREQUENCY).businessDayAdjustment(BUSS_ADJ).stubConvention(StubConvention.SHORT_FINAL).build()).payReceive(PAY).build());
 }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloor test1 = IborCapFloor.of(CAPFLOOR_LEG);

            coverImmutableBean(test1);
            IborCapFloorLeg capFloor = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();
            IborCapFloor    test2    = IborCapFloor.of(capFloor, PAY_LEG);

            coverBeanEquals(test1, test2);
        }
Example #6
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborCapFloorTrade test1 = sut();

            coverImmutableBean(test1);
            IborCapFloor      product = IborCapFloor.of(IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build());
            IborCapFloorTrade test2   = IborCapFloorTrade.builder().product(product).build();

            coverBeanEquals(test1, test2);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         IborCapFloorLeg other = (IborCapFloorLeg)obj;
         return(JodaBeanUtils.equal(payReceive, other.payReceive) && JodaBeanUtils.equal(paymentSchedule, other.paymentSchedule) && JodaBeanUtils.equal(paymentDateOffset, other.paymentDateOffset) && JodaBeanUtils.equal(currency, other.currency) && JodaBeanUtils.equal(notional, other.notional) && JodaBeanUtils.equal(calculation, other.calculation) && JodaBeanUtils.equal(capSchedule, other.capSchedule) && JodaBeanUtils.equal(floorSchedule, other.floorSchedule));
     }
     return(false);
 }
Example #8
0
 // summarize the main leg
 private void summarizeMainLeg(IborCapFloorLeg mainLeg, StringBuilder buf)
 {
     buf.Append(mainLeg.Index);
     buf.Append(' ');
     if (mainLeg.CapSchedule.Present)
     {
         buf.Append("Cap ");
         buf.Append(SummarizerUtils.percent(mainLeg.CapSchedule.get().InitialValue));
     }
     if (mainLeg.FloorSchedule.Present)
     {
         buf.Append("Floor ");
         buf.Append(SummarizerUtils.percent(mainLeg.FloorSchedule.get().InitialValue));
     }
 }
        public virtual void test_builder_min()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            assertEquals(test.Calculation, RATE_CALCULATION);
            assertEquals(test.CapSchedule.Present, false);
            assertEquals(test.FloorSchedule.get(), FLOOR);
            assertEquals(test.Currency, EUR);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PaymentDateOffset, DaysAdjustment.NONE);
            assertEquals(test.PaymentSchedule, SCHEDULE);
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.StartDate, AdjustableDate.of(START, BUSS_ADJ));
            assertEquals(test.EndDate, AdjustableDate.of(END, BUSS_ADJ));
        }
        public virtual void test_builder_full()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).capSchedule(CAP).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build();

            assertEquals(test.Calculation, RATE_CALCULATION);
            assertEquals(test.CapSchedule.get(), CAP);
            assertEquals(test.FloorSchedule.Present, false);
            assertEquals(test.Currency, GBP);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.PaymentDateOffset, PAYMENT_OFFSET);
            assertEquals(test.PaymentSchedule, SCHEDULE);
            assertEquals(test.PayReceive, PAY);
            assertEquals(test.StartDate, AdjustableDate.of(START, BUSS_ADJ));
            assertEquals(test.EndDate, AdjustableDate.of(END, BUSS_ADJ));
            assertEquals(test.Index, EUR_EURIBOR_3M);
        }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 2124672084:         // capFloorLeg
                    this.capFloorLeg = (IborCapFloorLeg)newValue;
                    break;

                case -995239866:         // payLeg
                    this.payLeg = (SwapLeg)newValue;
                    break;

                default:
                    throw new NoSuchElementException("Unknown property: " + propertyName);
                }
                return(this);
            }
        public virtual void test_resolve_floor()
        {
            IborCapFloorLeg @base = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).currency(GBP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(PAY).build();

            LocalDate[] unadjustedDates        = new LocalDate[] { START, START.plusMonths(3), START.plusMonths(6), START.plusMonths(9), START.plusMonths(12) };
            IborCapletFloorletPeriod[] periods = new IborCapletFloorletPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate start        = BUSS_ADJ.adjust(unadjustedDates[i], REF_DATA);
                LocalDate end          = BUSS_ADJ.adjust(unadjustedDates[i + 1], REF_DATA);
                double    yearFraction = EUR_EURIBOR_3M.DayCount.relativeYearFraction(start, end);
                LocalDate fixingDate   = RATE_CALCULATION.FixingDateOffset.adjust(start, REF_DATA);
                periods[i] = IborCapletFloorletPeriod.builder().floorlet(STRIKES[i]).currency(GBP).startDate(start).endDate(end).unadjustedStartDate(unadjustedDates[i]).unadjustedEndDate(unadjustedDates[i + 1]).paymentDate(PAYMENT_OFFSET.adjust(end, REF_DATA)).notional(-NOTIONALS[i]).iborRate(IborRateComputation.of(EUR_EURIBOR_3M, fixingDate, REF_DATA)).yearFraction(yearFraction).build();
            }
            ResolvedIborCapFloorLeg expected = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(periods).payReceive(PAY).build();
            ResolvedIborCapFloorLeg computed = @base.resolve(REF_DATA);

            assertEquals(computed, expected);
        }
        public virtual void test_resolve_cap()
        {
            IborRateCalculation rateCalc = IborRateCalculation.builder().index(EUR_EURIBOR_3M).fixingRelativeTo(FixingRelativeTo.PERIOD_END).fixingDateOffset(EUR_EURIBOR_3M.FixingDateOffset).build();
            IborCapFloorLeg     @base    = IborCapFloorLeg.builder().calculation(rateCalc).capSchedule(CAP).notional(NOTIONAL).paymentDateOffset(PAYMENT_OFFSET).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            LocalDate[] unadjustedDates        = new LocalDate[] { START, START.plusMonths(3), START.plusMonths(6), START.plusMonths(9), START.plusMonths(12) };
            IborCapletFloorletPeriod[] periods = new IborCapletFloorletPeriod[4];
            for (int i = 0; i < 4; ++i)
            {
                LocalDate start        = BUSS_ADJ.adjust(unadjustedDates[i], REF_DATA);
                LocalDate end          = BUSS_ADJ.adjust(unadjustedDates[i + 1], REF_DATA);
                double    yearFraction = EUR_EURIBOR_3M.DayCount.relativeYearFraction(start, end);
                periods[i] = IborCapletFloorletPeriod.builder().caplet(CAP.InitialValue).currency(EUR).startDate(start).endDate(end).unadjustedStartDate(unadjustedDates[i]).unadjustedEndDate(unadjustedDates[i + 1]).paymentDate(PAYMENT_OFFSET.adjust(end, REF_DATA)).notional(NOTIONALS[i]).iborRate(IborRateComputation.of(EUR_EURIBOR_3M, rateCalc.FixingDateOffset.adjust(end, REF_DATA), REF_DATA)).yearFraction(yearFraction).build();
            }
            ResolvedIborCapFloorLeg expected = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(periods).payReceive(RECEIVE).build();
            ResolvedIborCapFloorLeg computed = @base.resolve(REF_DATA);

            assertEquals(computed, expected);
        }
 /// <summary>
 /// Obtains an instance from a cap/floor leg and a pay leg.
 /// </summary>
 /// <param name="capFloorLeg">  the cap/floor leg </param>
 /// <param name="payLeg">  the pay leg </param>
 /// <returns> the cap/floor </returns>
 public static IborCapFloor of(IborCapFloorLeg capFloorLeg, SwapLeg payLeg)
 {
     return(new IborCapFloor(capFloorLeg, payLeg));
 }
 //-------------------------------------------------------------------------
 /// <summary>
 /// Obtains an instance from a cap/floor leg with no pay leg.
 /// <para>
 /// The pay leg is absent in the resulting cap/floor.
 ///
 /// </para>
 /// </summary>
 /// <param name="capFloorLeg">  the cap/floor leg </param>
 /// <returns> the cap/floor </returns>
 public static IborCapFloor of(IborCapFloorLeg capFloorLeg)
 {
     return(new IborCapFloor(capFloorLeg, null));
 }
        public virtual void test_serialization()
        {
            IborCapFloorLeg test = IborCapFloorLeg.builder().calculation(RATE_CALCULATION).floorSchedule(FLOOR).notional(NOTIONAL).paymentSchedule(SCHEDULE).payReceive(RECEIVE).build();

            assertSerialization(test);
        }