Esempio n. 1
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ResolvedIborCapFloorLeg test1 = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1, PERIOD_2, PERIOD_3, PERIOD_4).payReceive(RECEIVE).build();

            coverImmutableBean(test1);
            ResolvedIborCapFloorLeg test2 = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_2, PERIOD_3).payReceive(PAY).build();

            coverBeanEquals(test1, test2);
        }
 // collect the set of indices
 private static ImmutableSet <Index> buildIndices(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
 {
     ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
     builder.add(capFloorLeg.Index);
     if (payLeg != null)
     {
         payLeg.collectIndices(builder);
     }
     return(builder.build());
 }
 // collect the set of currencies
 private static ImmutableSet <Currency> buildCurrencies(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
 {
     ImmutableSet.Builder <Currency> builder = ImmutableSet.builder();
     builder.add(capFloorLeg.Currency);
     if (payLeg != null)
     {
         builder.add(payLeg.Currency);
     }
     return(builder.build());
 }
Esempio n. 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ResolvedIborCapFloor test1 = ResolvedIborCapFloor.of(CAPFLOOR_LEG, PAY_LEG);

            coverImmutableBean(test1);
            ResolvedIborCapFloorLeg capFloor = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1).payReceive(PAY).build();
            ResolvedIborCapFloor    test2    = ResolvedIborCapFloor.of(capFloor);

            coverBeanEquals(test1, test2);
        }
Esempio n. 5
0
        public virtual void test_builder_fail()
        {
            // two currencies
            IborCapletFloorletPeriod periodGbp = IborCapletFloorletPeriod.builder().caplet(STRIKE).notional(NOTIONAL).currency(GBP).startDate(LocalDate.of(2011, 6, 17)).endDate(LocalDate.of(2011, 9, 19)).unadjustedStartDate(LocalDate.of(2011, 6, 17)).unadjustedEndDate(LocalDate.of(2011, 9, 17)).paymentDate(LocalDate.of(2011, 9, 21)).iborRate(IborRateComputation.of(EUR_EURIBOR_3M, LocalDate.of(2011, 9, 15), REF_DATA)).yearFraction(0.2611).build();

            assertThrowsIllegalArg(() => ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1, periodGbp).payReceive(RECEIVE).build());
            // two indices
            IborCapletFloorletPeriod periodLibor = IborCapletFloorletPeriod.builder().caplet(STRIKE).notional(NOTIONAL).currency(EUR).startDate(LocalDate.of(2011, 6, 17)).endDate(LocalDate.of(2011, 9, 19)).unadjustedStartDate(LocalDate.of(2011, 6, 17)).unadjustedEndDate(LocalDate.of(2011, 9, 17)).paymentDate(LocalDate.of(2011, 9, 21)).iborRate(IborRateComputation.of(GBP_LIBOR_3M, LocalDate.of(2011, 9, 15), REF_DATA)).yearFraction(0.2611).build();

            assertThrowsIllegalArg(() => ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1, periodLibor).payReceive(RECEIVE).build());
        }
        //-------------------------------------------------------------------------
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private ResolvedIborCapFloor(ResolvedIborCapFloorLeg capFloorLeg, com.opengamma.strata.product.swap.ResolvedSwapLeg payLeg)
        private ResolvedIborCapFloor(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
        {
            JodaBeanUtils.notNull(capFloorLeg, "capFloorLeg");
            if (payLeg != null)
            {
                ArgChecker.isFalse(payLeg.PayReceive.Equals(capFloorLeg.PayReceive), "Legs must have different Pay/Receive flag, but both were {}", payLeg.PayReceive);
            }
            this.capFloorLeg = capFloorLeg;
            this.payLeg      = payLeg;
            this.currencies  = buildCurrencies(capFloorLeg, payLeg);
            this.indices     = buildIndices(capFloorLeg, payLeg);
        }
Esempio n. 7
0
        public virtual void test_builder()
        {
            ResolvedIborCapFloorLeg test = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1, PERIOD_2, PERIOD_3, PERIOD_4).payReceive(RECEIVE).build();

            assertEquals(test.CapletFloorletPeriods, ImmutableList.of(PERIOD_1, PERIOD_2, PERIOD_3, PERIOD_4));
            assertEquals(test.PayReceive, RECEIVE);
            assertEquals(test.StartDate, PERIOD_1.StartDate);
            assertEquals(test.EndDate, PERIOD_4.EndDate);
            assertEquals(test.FinalPeriod, PERIOD_4);
            assertEquals(test.FinalFixingDateTime, PERIOD_4.FixingDateTime);
            assertEquals(test.Currency, EUR);
            assertEquals(test.Index, EUR_EURIBOR_3M);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ResolvedIborCapFloorLeg other = (ResolvedIborCapFloorLeg)obj;
         return(JodaBeanUtils.equal(payReceive, other.payReceive) && JodaBeanUtils.equal(capletFloorletPeriods, other.capletFloorletPeriods));
     }
     return(false);
 }
            public override Builder set(string propertyName, object newValue)
            {
                switch (propertyName.GetHashCode())
                {
                case 2124672084:         // capFloorLeg
                    this.capFloorLeg = (ResolvedIborCapFloorLeg)newValue;
                    break;

                case -995239866:         // payLeg
                    this.payLeg = (ResolvedSwapLeg)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 ResolvedIborCapFloor of(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
 {
     ArgChecker.notNull(capFloorLeg, "capFloorLeg");
     ArgChecker.notNull(payLeg, "payLeg");
     return(new ResolvedIborCapFloor(capFloorLeg, payLeg));
 }
        private readonly ImmutableSet <Index> indices;  // not a property, derived and cached from input data

        //-------------------------------------------------------------------------
        /// <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 ResolvedIborCapFloor of(ResolvedIborCapFloorLeg capFloorLeg)
        {
            ArgChecker.notNull(capFloorLeg, "capFloorLeg");
            return(new ResolvedIborCapFloor(capFloorLeg, null));
        }
Esempio n. 14
0
        public virtual void test_serialization()
        {
            ResolvedIborCapFloorLeg test = ResolvedIborCapFloorLeg.builder().capletFloorletPeriods(PERIOD_1, PERIOD_2, PERIOD_3, PERIOD_4).payReceive(RECEIVE).build();

            assertSerialization(test);
        }