/** * Builder of Ibor-like coupon from the fixing date and the index. The payment and accrual dates * are the one of the fixing period. * * @param notional Coupon notional. * @param fixingDate The coupon fixing date. * @param index The coupon Ibor index. * @param calendar The holiday calendar for the ibor index. * @return The Ibor coupon. */ public static CouponIborDefinition from( final double notional, final ZonedDateTime fixingDate, final IborIndex index, final Calendar calendar) { ArgumentChecker.notNull(fixingDate, "fixing date"); ArgumentChecker.notNull(index, "index"); final ZonedDateTime fixingPeriodStartDate = ScheduleCalculator.getAdjustedDate(fixingDate, index.getSpotLag(), calendar); final ZonedDateTime fixingPeriodEndDate = ScheduleCalculator.getAdjustedDate( fixingPeriodStartDate, index.getTenor(), index.getBusinessDayConvention(), calendar, index.isEndOfMonth()); final double fixingPeriodAccrualFactor = index .getDayCount() .getDayCountFraction(fixingPeriodStartDate, fixingPeriodEndDate, calendar); return new CouponIborDefinition( index.getCurrency(), fixingPeriodEndDate, fixingPeriodStartDate, fixingPeriodEndDate, fixingPeriodAccrualFactor, notional, fixingDate, index, calendar); }
static { LEGS_DEFINITION[0] = AnnuityDefinitionBuilder.couponFixed( EUR, SETTLEMENT_DATE, MATURITY_DATE, EUR1YEURIBOR6M.getFixedLegPeriod(), TARGET, EUR1YEURIBOR6M.getFixedLegDayCount(), EUR1YEURIBOR6M.getBusinessDayConvention(), EUR1YEURIBOR6M.isEndOfMonth(), NOTIONAL, SPREAD, IS_PAYER_SPREAD, STUB, 0); LEGS_DEFINITION[1] = AnnuityDefinitionBuilder.couponIbor( SETTLEMENT_DATE, MATURITY_DATE, EURIBOR3M.getTenor(), NOTIONAL, EURIBOR3M, IS_PAYER_SPREAD, EURIBOR3M.getDayCount(), EURIBOR3M.getBusinessDayConvention(), EURIBOR3M.isEndOfMonth(), TARGET, STUB, 0); LEGS_DEFINITION[2] = AnnuityDefinitionBuilder.couponIbor( SETTLEMENT_DATE, MATURITY_DATE, EURIBOR6M.getTenor(), NOTIONAL, EURIBOR6M, !IS_PAYER_SPREAD, EURIBOR6M.getDayCount(), EURIBOR6M.getBusinessDayConvention(), EURIBOR6M.isEndOfMonth(), TARGET, STUB, 0); }
/** * Compute the end date of a period from the start date, a period and a Ibor index. The index is * used for the conventions. * * @param startDate The period start date. * @param tenor The period tenor. * @param index The Ibor index. * @param calendar The holiday calendar. * @return The end date. */ public static ZonedDateTime getAdjustedDate( final ZonedDateTime startDate, final Period tenor, final IborIndex index, final Calendar calendar) { ArgumentChecker.notNull(index, "Index"); return getAdjustedDate( startDate, tenor, index.getBusinessDayConvention(), calendar, index.isEndOfMonth()); }
@Override protected void buildMessage( final FudgeSerializer serializer, final MutableFudgeMsg message, final IborIndex object) { message.add(SPOT_LAG_FIELD, object.getSpotLag()); message.add(DAY_COUNT_FIELD, object.getDayCount().getConventionName()); message.add( BUSINESS_DAY_CONVENTION_FIELD, object.getBusinessDayConvention().getConventionName()); message.add(EOM_FIELD, object.isEndOfMonth()); message.add(TENOR_FIELD, object.getTenor().toString()); message.add(NAME_FIELD, object.getName()); message.add(CURRENCY_FIELD, object.getCurrency().getCode()); }
/** * Compute a schedule of adjusted dates from a start date, total tenor and a Ibor index. * * @param startDate The start date. * @param tenorTotal The total tenor. * @param stubShort In case the the periods do not fit exactly between start and end date, is the * remaining interval shorter (true) or longer (false) than the requested period. * @param fromEnd The dates in the schedule can be computed from the end date (true) or from the * start date (false). * @param index The related ibor index. The period tenor, business day convention, calendar and * EOM rule of the index are used. * @param calendar The holiday calendar. * @return The adjusted dates schedule (not including the start date). */ public static ZonedDateTime[] getAdjustedDateSchedule( final ZonedDateTime startDate, final Period tenorTotal, final boolean stubShort, final boolean fromEnd, final IborIndex index, final Calendar calendar) { return getAdjustedDateSchedule( startDate, tenorTotal, index.getTenor(), stubShort, fromEnd, index.getBusinessDayConvention(), calendar, index.isEndOfMonth()); }
@Test /** Tests the present value for curves with seasonal adjustment. */ public void presentValueSeasonality() { MarketBundle marketSeason = MarketDataSets.createMarket2(PRICING_DATE); int tenorYear = 5; double notional = 100000000; ZonedDateTime settleDate = ScheduleCalculator.getAdjustedDate(PRICING_DATE, USDLIBOR3M.getSpotLag(), CALENDAR_USD); ZonedDateTime paymentDate = ScheduleCalculator.getAdjustedDate( settleDate, Period.ofYears(tenorYear), BUSINESS_DAY, CALENDAR_USD, USDLIBOR3M.isEndOfMonth()); double weightSettle = 1.0 - (settleDate.getDayOfMonth() - 1.0) / settleDate.getMonthOfYear().getLastDayOfMonth(settleDate.isLeapYear()); double indexStart = weightSettle * 225.964 + (1 - weightSettle) * 225.722; CouponInflationZeroCouponInterpolationDefinition zeroCouponUsdDefinition = CouponInflationZeroCouponInterpolationDefinition.from( settleDate, paymentDate, notional, PRICE_INDEX_US, indexStart, MONTH_LAG, false); CouponInflationZeroCouponInterpolation zeroCouponUsd = zeroCouponUsdDefinition.toDerivative(PRICING_DATE, "not used"); CurrencyAmount pvInflation = METHOD.presentValue(zeroCouponUsd, marketSeason); double df = MARKET .getCurve(zeroCouponUsd.getCurrency()) .getDiscountFactor(zeroCouponUsd.getPaymentTime()); double indexMonth0 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[0]); double indexMonth1 = marketSeason.getCurve(PRICE_INDEX_US).getPriceIndex(zeroCouponUsd.getReferenceEndTime()[1]); double finalIndex = zeroCouponUsdDefinition.getWeight() * indexMonth0 + (1 - zeroCouponUsdDefinition.getWeight()) * indexMonth1; double pvExpected = (finalIndex / indexStart - 1) * df * notional; assertEquals( "PV in market with seasonal adjustment", pvExpected, pvInflation.getAmount(), 1E-2); }
/** * Constructor of a Ibor-like floating coupon from the coupon details and the Ibor index. The * payment currency is the index currency. The fixing dates and accrual factors are inferred from * the index. * * @param currency The coupon currency. * @param paymentDate The coupon payment date. * @param accrualStartDate The start date of the accrual period. * @param accrualEndDate The end date of the accrual period. * @param paymentAccrualFactor The accrual factor of the accrual period. * @param notional The coupon notional. * @param fixingDate The coupon fixing date. * @param index The coupon Ibor index. Should of the same currency as the payment. * @param calendar The holiday calendar for the ibor index. */ public CouponIborDefinition( final Currency currency, final ZonedDateTime paymentDate, final ZonedDateTime accrualStartDate, final ZonedDateTime accrualEndDate, final double paymentAccrualFactor, final double notional, final ZonedDateTime fixingDate, final IborIndex index, final Calendar calendar) { super( currency, paymentDate, accrualStartDate, accrualEndDate, paymentAccrualFactor, notional, fixingDate); ArgumentChecker.notNull(index, "index"); ArgumentChecker.notNull(calendar, "calendar"); ArgumentChecker.isTrue( currency.equals(index.getCurrency()), "index currency different from payment currency"); _index = index; _fixingPeriodStartDate = ScheduleCalculator.getAdjustedDate(fixingDate, _index.getSpotLag(), calendar); _fixingPeriodEndDate = ScheduleCalculator.getAdjustedDate( _fixingPeriodStartDate, index.getTenor(), index.getBusinessDayConvention(), calendar, index.isEndOfMonth()); _fixingPeriodAccrualFactor = index .getDayCount() .getDayCountFraction(_fixingPeriodStartDate, _fixingPeriodEndDate, calendar); _calendar = calendar; }