本文整理汇总了Java中org.threeten.bp.ZonedDateTime.plusYears方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.plusYears方法的具体用法?Java ZonedDateTime.plusYears怎么用?Java ZonedDateTime.plusYears使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threeten.bp.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.plusYears方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchedule
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
Validate.notNull(startDate, "start date");
Validate.notNull(endDate, "end date");
Validate.isTrue(startDate.isBefore(endDate) || startDate.equals(endDate));
if (startDate.equals(endDate)) {
if (MonthDay.from(startDate).equals(_monthDay)) {
return new ZonedDateTime[] {startDate};
}
throw new IllegalArgumentException("Start date and end date were the same but the day of month and month of year were not those required");
}
ZonedDateTime date = startDate.with(_monthDay);
if (date.isBefore(startDate)) {
date = date.plusYears(1);
}
final List<ZonedDateTime> dates = new ArrayList<>();
while (!date.isAfter(endDate)) {
dates.add(date);
date = date.plusYears(1);
}
return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
示例2: getSchedule
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
public ZonedDateTime[] getSchedule(final ZonedDateTime startDate, final ZonedDateTime endDate) {
ArgumentChecker.notNull(startDate, "start date");
ArgumentChecker.notNull(endDate, "end date");
ArgumentChecker.isFalse(startDate.isAfter(endDate), "start date must not be after end date");
if (startDate.equals(endDate)) {
if (startDate.getDayOfMonth() == 1 && startDate.getMonth() == Month.JANUARY) {
return new ZonedDateTime[] {startDate};
}
throw new IllegalArgumentException("Start date and end date were the same but neither was the first day of the year");
}
final List<ZonedDateTime> dates = new ArrayList<>();
ZonedDateTime date = startDate.with(TemporalAdjusters.firstDayOfYear());
if (date.isBefore(startDate)) {
date = date.plusYears(1);
}
while (!date.isAfter(endDate)) {
dates.add(date);
date = date.plusYears(1);
}
return dates.toArray(EMPTY_ZONED_DATE_TIME_ARRAY);
}
示例3: couponIborStandard
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborStandard() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponIborDefinition> leg = AnnuityDefinitionBuilder.couponIbor(settlementDate, maturityDate, paymentPeriod, NOTIONAL,
USDLIBOR6M, true, USDLIBOR6M.getDayCount(), USDLIBOR6M.getBusinessDayConvention(), USDLIBOR6M.isEndOfMonth(), NYC, stub, 0);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getAccrualStartDate(), leg.getNthPayment(loopcpn).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopcpn).getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -leg.getNthPayment(loopcpn).getNotional()); // Payer
}
}
示例4: couponIborStandardNotionalStartEnd
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborStandardNotionalStartEnd() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
// Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponDefinition> leg = AnnuityDefinitionBuilder.couponIborWithNotional(settlementDate, maturityDate, NOTIONAL,
USDLIBOR6M, true, NYC, stub, 0, true, true);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", expectedPaymentDates.length + 2, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: couponFixed", NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(0)).getAmount());
assertEquals("AnnuityDefinitionBuilder: couponFixed", -NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(leg.getNumberOfPayments() - 1)).getAmount());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", settlementDate, leg.getNthPayment(0).getPaymentDate());
assertTrue("AnnuityDefinitionBuilder: Coupon Ibor", leg.getNthPayment(1) instanceof CouponIborDefinition);
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", settlementDate, ((CouponIborDefinition) leg.getNthPayment(1)).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments() - 2; loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn + 1).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborDefinition) leg.getNthPayment(loopcpn + 1)).getAccrualStartDate(),
((CouponIborDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(((CouponIborDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -((CouponIborDefinition) leg.getNthPayment(loopcpn + 1)).getNotional()); // Payer
}
}
示例5: couponIborSpreadStandard
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborSpreadStandard() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponIborSpreadDefinition> leg = AnnuityDefinitionBuilder.couponIborSpread(settlementDate, maturityDate, paymentPeriod, NOTIONAL, SPREAD,
USDLIBOR6M, true, USDLIBOR6M.getDayCount(), USDLIBOR6M.getBusinessDayConvention(), USDLIBOR6M.isEndOfMonth(), NYC, stub, 0);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getAccrualStartDate(), leg.getNthPayment(loopcpn).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopcpn).getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -leg.getNthPayment(loopcpn).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, leg.getNthPayment(loopcpn).getSpread());
}
}
示例6: couponIborSpreadStandardNotionalStartEnd
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborSpreadStandardNotionalStartEnd() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
// Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponDefinition> leg = AnnuityDefinitionBuilder.couponIborSpreadWithNotional(settlementDate, maturityDate, NOTIONAL,
SPREAD, USDLIBOR6M, true, NYC, stub, 0, true, true);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length + 2, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: couponFixed", NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(0)).getAmount());
assertEquals("AnnuityDefinitionBuilder: couponFixed", -NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(leg.getNumberOfPayments() - 1)).getAmount());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, ((CouponIborSpreadDefinition) leg.getNthPayment(1)).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments() - 2; loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn + 1).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getAccrualStartDate(),
((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getSpread());
}
}
示例7: couponIborCompoundingStandard
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborCompoundingStandard() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponIborCompoundingDefinition> leg = AnnuityDefinitionBuilder.couponIborCompounding(settlementDate, maturityDate, paymentPeriod, NOTIONAL,
USDLIBOR3M, stub, true, USDLIBOR3M.getBusinessDayConvention(), USDLIBOR3M.isEndOfMonth(), NYC, stub);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", expectedPaymentDates.length, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", settlementDate, leg.getNthPayment(0).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", leg.getNthPayment(loopcpn).getAccrualStartDate(), leg.getNthPayment(loopcpn).getFixingPeriodStartDates()[0]);
for (int loopsub = 0; loopsub < leg.getNthPayment(loopcpn).getAccrualEndDates().length; loopsub++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", leg.getNthPayment(loopcpn).getFixingPeriodEndDates()[loopsub],
ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopcpn).getFixingPeriodStartDates()[loopsub], USDLIBOR3M, NYC));
}
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Compounding", NOTIONAL, -leg.getNthPayment(loopcpn).getNotional()); // Payer
}
}
示例8: couponIborCompoundingSpreadStandard
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborCompoundingSpreadStandard() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponIborCompoundingSpreadDefinition> leg = AnnuityDefinitionBuilder.couponIborCompoundingSpread(settlementDate, maturityDate, paymentPeriod, NOTIONAL, SPREAD,
USDLIBOR3M, stub, true, USDLIBOR3M.getBusinessDayConvention(), USDLIBOR3M.isEndOfMonth(), NYC, stub);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getAccrualStartDate(), leg.getNthPayment(loopcpn).getFixingPeriodStartDates()[0]);
for (int loopsub = 0; loopsub < leg.getNthPayment(loopcpn).getAccrualEndDates().length; loopsub++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getFixingPeriodEndDates()[loopsub],
ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopcpn).getFixingPeriodStartDates()[loopsub], USDLIBOR3M, NYC));
}
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -leg.getNthPayment(loopcpn).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, leg.getNthPayment(loopcpn).getSpread());
}
}
示例9: couponIborCompoundingFlatSpreadStandard
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborCompoundingFlatSpreadStandard() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponIborCompoundingFlatSpreadDefinition> leg = AnnuityDefinitionBuilder.couponIborCompoundingFlatSpread(settlementDate, maturityDate, paymentPeriod, NOTIONAL, SPREAD,
USDLIBOR3M, stub, true, USDLIBOR3M.getBusinessDayConvention(), USDLIBOR3M.isEndOfMonth(), NYC, stub);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getAccrualStartDate(), leg.getNthPayment(loopcpn).getFixingSubperiodStartDates()[0]);
for (int loopsub = 0; loopsub < leg.getNthPayment(loopcpn).getSubperiodsAccrualStartDates().length; loopsub++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn).getFixingSubperiodEndDates()[loopsub],
ScheduleCalculator.getAdjustedDate(leg.getNthPayment(loopcpn).getFixingSubperiodStartDates()[loopsub], USDLIBOR3M, NYC));
}
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -leg.getNthPayment(loopcpn).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, leg.getNthPayment(loopcpn).getSpread());
}
}
示例10: couponONArithmeticAverageSpreadSimplified
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponONArithmeticAverageSpreadSimplified() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
Period paymentPeriod = USDLIBOR3M.getTenor();
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponONArithmeticAverageSpreadSimplifiedDefinition> legONAA = AnnuityDefinitionBuilder.couponONArithmeticAverageSpreadSimplified(settlementDate, maturityDate, paymentPeriod,
NOTIONAL, SPREAD, FED_FUND, true, USDLIBOR3M.getBusinessDayConvention(), USDLIBOR3M.isEndOfMonth(), NYC, stub);
AnnuityDefinition<CouponIborSpreadDefinition> legLibor3M = AnnuityDefinitionBuilder.couponIborSpread(settlementDate, maturityDate, paymentPeriod, NOTIONAL, SPREAD,
USDLIBOR3M, true, USDLIBOR3M.getDayCount(), USDLIBOR3M.getBusinessDayConvention(), USDLIBOR3M.isEndOfMonth(), NYC, stub, 0);
assertEquals("AnnuityDefinitionBuilder: couponONArithmeticAverageSpreadSimplified", legLibor3M.getNumberOfPayments(), legONAA.getNumberOfPayments());
for (int loopcpn = 0; loopcpn < legONAA.getNumberOfPayments(); loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", legLibor3M.getNthPayment(loopcpn).getPaymentDate(), legONAA.getNthPayment(loopcpn).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", legLibor3M.getNthPayment(loopcpn).getAccrualStartDate(), legONAA.getNthPayment(loopcpn).getAccrualStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", legLibor3M.getNthPayment(loopcpn).getAccrualEndDate(), legONAA.getNthPayment(loopcpn).getAccrualEndDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", legLibor3M.getNthPayment(loopcpn).getPaymentYearFraction(), legONAA.getNthPayment(loopcpn).getPaymentYearFraction());
assertEquals("AnnuityDefinitionBuilder: couponONArithmeticAverageSpreadSimplified", NOTIONAL, -legONAA.getNthPayment(loopcpn).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: couponONArithmeticAverageSpreadSimplified", SPREAD, legONAA.getNthPayment(loopcpn).getSpread());
}
}
示例11: couponIborStandardNotionalConventionStartEnd
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborStandardNotionalConventionStartEnd() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
// Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponDefinition> leg = AnnuityDefinitionBuilder.couponIborWithNotional(settlementDate, maturityDate, NOTIONAL,
USDLIBOR6M, ACT_365, PRECEDING, false, USDLIBOR6M.getTenor(), true, NYC, stub, 0, true, true);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 19),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 18) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", expectedPaymentDates.length + 2, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: couponFixed", NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(0)).getAmount());
assertEquals("AnnuityDefinitionBuilder: couponFixed", -NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(leg.getNumberOfPayments() - 1)).getAmount());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", settlementDate, leg.getNthPayment(0).getPaymentDate());
assertTrue("AnnuityDefinitionBuilder: Coupon Ibor", leg.getNthPayment(1) instanceof CouponIborDefinition);
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", settlementDate, ((CouponIborDefinition) leg.getNthPayment(1)).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments() - 2; loopcpn++) {
CouponIborDefinition cpn = ((CouponIborDefinition) leg.getNthPayment(loopcpn + 1));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn + 1).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", cpn.getAccrualStartDate(), cpn.getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", cpn.getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(cpn.getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", NOTIONAL, -cpn.getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", ACT_365.getDayCountFraction(cpn.getAccrualStartDate(), cpn.getAccrualEndDate()), cpn.getPaymentYearFraction());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", USDLIBOR6M.getDayCount().getDayCountFraction(cpn.getFixingPeriodStartDate(), cpn.getFixingPeriodEndDate()),
cpn.getFixingPeriodAccrualFactor());
}
}
示例12: couponIborSpreadStandardNotionalConventionStartEnd
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborSpreadStandardNotionalConventionStartEnd() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
// Period paymentPeriod = Period.ofMonths(6);
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponDefinition> leg = AnnuityDefinitionBuilder.couponIborSpreadWithNotional(settlementDate, maturityDate, NOTIONAL,
SPREAD, USDLIBOR6M, ACT_365, PRECEDING, false, USDLIBOR6M.getTenor(), true, NYC, stub, 0, true, true);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 19),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 18) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length + 2, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: couponFixed", NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(0)).getAmount());
assertEquals("AnnuityDefinitionBuilder: couponFixed", -NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(leg.getNumberOfPayments() - 1)).getAmount());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, ((CouponIborSpreadDefinition) leg.getNthPayment(1)).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments() - 2; loopcpn++) {
assertTrue("AnnuityDefinitionBuilder: Coupon Ibor Spread", leg.getNthPayment(loopcpn + 1) instanceof CouponIborSpreadDefinition);
CouponIborSpreadDefinition cpn = ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], cpn.getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", cpn.getAccrualStartDate(),
((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", cpn.getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(cpn.getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -cpn.getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, cpn.getSpread());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", ACT_365.getDayCountFraction(cpn.getAccrualStartDate(), cpn.getAccrualEndDate()), cpn.getPaymentYearFraction());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor", USDLIBOR6M.getDayCount().getDayCountFraction(cpn.getFixingPeriodStartDate(), cpn.getFixingPeriodEndDate()),
cpn.getFixingPeriodAccrualFactor());
}
}
示例13: couponIborSpreadStandardNotionalStartEndLag
import org.threeten.bp.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void couponIborSpreadStandardNotionalStartEndLag() {
ZonedDateTime settlementDate = DateUtils.getUTCDate(2013, 9, 20);
ZonedDateTime maturityDate = settlementDate.plusYears(2);
int payLag = 2;
final StubType stub = StubType.SHORT_START;
AnnuityDefinition<CouponDefinition> leg = AnnuityDefinitionBuilder.couponIborSpreadWithNotional(settlementDate, maturityDate, NOTIONAL,
SPREAD, USDLIBOR6M, true, NYC, stub, 2, true, true);
ZonedDateTime[] expectedPaymentDates = new ZonedDateTime[] {DateUtils.getUTCDate(2014, 3, 20), DateUtils.getUTCDate(2014, 9, 22),
DateUtils.getUTCDate(2015, 3, 20), DateUtils.getUTCDate(2015, 9, 21) };
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates.length + 2, leg.getNumberOfPayments());
assertEquals("AnnuityDefinitionBuilder: couponFixed", NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(0)).getAmount());
assertEquals("AnnuityDefinitionBuilder: couponFixed", -NOTIONAL, ((CouponFixedDefinition) leg.getNthPayment(leg.getNumberOfPayments() - 1)).getAmount());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, leg.getNthPayment(0).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", settlementDate, ((CouponIborSpreadDefinition) leg.getNthPayment(1)).getAccrualStartDate());
for (int loopcpn = 0; loopcpn < leg.getNumberOfPayments() - 2; loopcpn++) {
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ScheduleCalculator.getAdjustedDate(expectedPaymentDates[loopcpn], payLag, NYC),
leg.getNthPayment(loopcpn + 1).getPaymentDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", expectedPaymentDates[loopcpn], leg.getNthPayment(loopcpn + 1).getAccrualEndDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getAccrualStartDate(),
((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate());
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodEndDate(),
ScheduleCalculator.getAdjustedDate(((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getFixingPeriodStartDate(), USDLIBOR6M, NYC));
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", NOTIONAL, -((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getNotional()); // Payer
assertEquals("AnnuityDefinitionBuilder: Coupon Ibor Spread", SPREAD, ((CouponIborSpreadDefinition) leg.getNthPayment(loopcpn + 1)).getSpread());
}
}