@Test(dataProvider = "create") public void test_parse(Frequency test, Period period, String toString) { assertEquals(Frequency.parse(toString), test); assertEquals(Frequency.parse(toString).getPeriod(), period); }
@Test(dataProvider = "create") public void test_of_int(Frequency test, Period period, String toString) { assertEquals(test.getPeriod(), period); assertEquals(test.toString(), toString); assertEquals(test.isTerm(), false); }
@Test(dataProvider = "create") public void test_of_Period(Frequency test, Period period, String toString) { assertEquals(Frequency.of(period), test); assertEquals(Frequency.of(period).getPeriod(), period); }
ArgChecker.notNull(other, "other"); if (isMonthBased() && other.isMonthBased()) { long paymentMonths = getPeriod().toTotalMonths(); long accrualMonths = other.getPeriod().toTotalMonths(); if ((paymentMonths % accrualMonths) == 0) { return Math.toIntExact(paymentMonths / accrualMonths); long paymentDays = getPeriod().getDays(); long accrualDays = other.getPeriod().getDays(); if ((paymentDays % accrualDays) == 0) { return Math.toIntExact(paymentDays / accrualDays);
@Test(dataProvider = "normalized") public void test_normalized(Period period, Period normalized) { assertEquals(Frequency.of(period).normalized().getPeriod(), normalized); }
@Test(dataProvider = "ofYears") public void test_ofYears(int years, Period normalized, String str) { assertEquals(Frequency.ofYears(years).getPeriod(), normalized); assertEquals(Frequency.ofYears(years).toString(), str); }
@Test(dataProvider = "ofMonths") public void test_ofMonths(int months, Period normalized, String str) { assertEquals(Frequency.ofMonths(months).getPeriod(), normalized); assertEquals(Frequency.ofMonths(months).toString(), str); }
private static FloatingRateIndex parseIndex(CsvRow row, String leg) { Optional<String> fixedRateOpt = findValue(row, leg, FIXED_RATE_FIELD); Optional<String> indexOpt = findValue(row, leg, INDEX_FIELD); if (fixedRateOpt.isPresent()) { if (indexOpt.isPresent()) { throw new IllegalArgumentException( "Swap leg must not define both '" + leg + FIXED_RATE_FIELD + "' and '" + leg + INDEX_FIELD + "'"); } return null; } if (!indexOpt.isPresent()) { throw new IllegalArgumentException( "Swap leg must define either '" + leg + FIXED_RATE_FIELD + "' or '" + leg + INDEX_FIELD + "'"); } // use FloatingRateName to identify Ibor vs other String indexStr = indexOpt.get(); FloatingRateName frn = FloatingRateName.parse(indexStr); if (frn.getType() == FloatingRateType.IBOR) { // re-parse Ibor using tenor, which ensures tenor picked up from indexStr if present Frequency freq = Frequency.parse(getValue(row, leg, FREQUENCY_FIELD)); Tenor iborTenor = freq.isTerm() ? frn.getDefaultTenor() : Tenor.of(freq.getPeriod()); return FloatingRateIndex.parse(indexStr, iborTenor); } return frn.toFloatingRateIndex(); }
.frequency(Frequency.of(frequency.getPeriod().multipliedBy(groupSize))) .rollConvention(rollConvention) .build();
@ImmutableConstructor private IborCapFloorLeg( PayReceive payReceive, PeriodicSchedule paymentSchedule, DaysAdjustment paymentDateOffset, Currency currency, ValueSchedule notional, IborRateCalculation calculation, ValueSchedule capSchedule, ValueSchedule floorSchedule) { this.payReceive = ArgChecker.notNull(payReceive, "payReceive"); this.paymentSchedule = ArgChecker.notNull(paymentSchedule, "paymentSchedule"); this.paymentDateOffset = ArgChecker.notNull(paymentDateOffset, "paymentDateOffset"); this.currency = currency != null ? currency : calculation.getIndex().getCurrency(); this.notional = notional; this.calculation = ArgChecker.notNull(calculation, "calculation"); this.capSchedule = capSchedule; this.floorSchedule = floorSchedule; ArgChecker.isTrue(!this.getPaymentSchedule().getStubConvention().isPresent() || this.getPaymentSchedule().getStubConvention().get().equals(StubConvention.NONE), "Stub period is not allowed"); ArgChecker.isFalse(this.getCapSchedule().isPresent() == this.getFloorSchedule().isPresent(), "One of cap schedule and floor schedule should be empty"); ArgChecker.isTrue(this.getCalculation().getIndex().getTenor().getPeriod().equals(this.getPaymentSchedule() .getFrequency().getPeriod()), "Payment frequency period should be the same as index tenor period"); }
Period newFrequency = frequency.getPeriod().multipliedBy(groupSize); throw new ScheduleException( "Unable to merge schedule, firstRegularStartDate {} and lastRegularEndDate {} cannot be used to " + .frequency(Frequency.of(frequency.getPeriod().multipliedBy(groupSize))) .rollConvention(rollConvention) .build();
cvDateTmp, cvDateTmp.plus(swap.getTenor()), swap.getPaymentFrequency().getPeriod(), swap.getDayCount(), curveDayCount,