/** * Gets the maturity date. * * @return the maturity date */ public LocalDate getMaturityDate() { return observation.getMaturityDate(); }
@Override public double rateIgnoringFixings(IborIndexObservation observation) { double relativeYearFraction = relativeYearFraction(observation.getMaturityDate()); return curve.yValue(relativeYearFraction); }
private DoublesPair weights(IborIndexObservation obs1, IborIndexObservation obs2, LocalDate endDate) { // weights: linear interpolation on the number of days between the fixing date and the maturity dates of the // actual coupons on one side and the maturity dates of the underlying deposit on the other side. long fixingEpochDay = obs1.getFixingDate().toEpochDay(); double days1 = obs1.getMaturityDate().toEpochDay() - fixingEpochDay; double days2 = obs2.getMaturityDate().toEpochDay() - fixingEpochDay; double daysN = endDate.toEpochDay() - fixingEpochDay; double weight1 = (days2 - daysN) / (days2 - days1); double weight2 = (daysN - days1) / (days2 - days1); return DoublesPair.of(weight1, weight2); }
@Override public double rateIgnoringFixings(IborIndexObservation observation) { LocalDate fixingStartDate = observation.getEffectiveDate(); LocalDate fixingEndDate = observation.getMaturityDate(); double accrualFactor = observation.getYearFraction(); // simply compounded forward rate from discount factors double dfStart = discountFactors.discountFactor(fixingStartDate); double dfEnd = discountFactors.discountFactor(fixingEndDate); return (dfStart / dfEnd - 1) / accrualFactor; }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 100346066: // index return ((IborIndexObservation) bean).getIndex(); case 1255202043: // fixingDate return ((IborIndexObservation) bean).getFixingDate(); case -930389515: // effectiveDate return ((IborIndexObservation) bean).getEffectiveDate(); case -414641441: // maturityDate return ((IborIndexObservation) bean).getMaturityDate(); case -1731780257: // yearFraction return ((IborIndexObservation) bean).getYearFraction(); } return super.propertyGet(bean, propertyName, quiet); }
@Override public CurrencyParameterSensitivities parameterSensitivity(IborRateSensitivity pointSensitivity) { LocalDate maturityDate = pointSensitivity.getObservation().getMaturityDate(); double relativeYearFraction = relativeYearFraction(maturityDate); UnitParameterSensitivity unitSensitivity = curve.yValueParameterSensitivity(relativeYearFraction); CurrencyParameterSensitivity sensitivity = unitSensitivity.multipliedBy(pointSensitivity.getCurrency(), pointSensitivity.getSensitivity()); return CurrencyParameterSensitivities.of(sensitivity); }
public void test_rateIgnoringFixings_onValuation_fixing() { SimpleIborIndexRates test = SimpleIborIndexRates.of(GBP_LIBOR_3M, DATE_VAL, CURVE, SERIES); double time = CURVE_DAY_COUNT.yearFraction(DATE_VAL, GBP_LIBOR_3M_VAL.getMaturityDate()); double expected = CURVE.yValue(time); assertEquals(test.rateIgnoringFixings(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); }
public void test_rate_onValuation_noFixing() { SimpleIborIndexRates test = SimpleIborIndexRates.of(GBP_LIBOR_3M, DATE_VAL, CURVE, SERIES_EMPTY); double time = CURVE_DAY_COUNT.yearFraction(DATE_VAL, GBP_LIBOR_3M_VAL.getMaturityDate()); double expected = CURVE.yValue(time); assertEquals(test.rate(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); assertEquals(test.rateIgnoringFixings(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); }
public void test_rate_afterValuation() { SimpleIborIndexRates test = SimpleIborIndexRates.of(GBP_LIBOR_3M, DATE_VAL, CURVE, SERIES); double time = CURVE_DAY_COUNT.yearFraction(DATE_VAL, GBP_LIBOR_3M_AFTER.getMaturityDate()); double expected = CURVE.yValue(time); assertEquals(test.rate(GBP_LIBOR_3M_AFTER), expected, TOLERANCE_RATE); }
public void test_rateSensitivity() { RatesProvider mockProv = mock(RatesProvider.class); IborIndexRates mockRates3M = mock(IborIndexRates.class); IborIndexRates mockRates6M = mock(IborIndexRates.class); when(mockProv.iborIndexRates(GBP_LIBOR_3M)).thenReturn(mockRates3M); when(mockProv.iborIndexRates(GBP_LIBOR_6M)).thenReturn(mockRates6M); when(mockRates3M.ratePointSensitivity(GBP_LIBOR_3M_OBS)).thenReturn(SENSITIVITY3); when(mockRates6M.ratePointSensitivity(GBP_LIBOR_6M_OBS)).thenReturn(SENSITIVITY6); IborInterpolatedRateComputation ro = IborInterpolatedRateComputation.of(GBP_LIBOR_3M, GBP_LIBOR_6M, FIXING_DATE, REF_DATA); ForwardIborInterpolatedRateComputationFn obsFn = ForwardIborInterpolatedRateComputationFn.DEFAULT; LocalDate fixingEndDate3M = GBP_LIBOR_3M_OBS.getMaturityDate(); LocalDate fixingEndDate6M = GBP_LIBOR_6M_OBS.getMaturityDate(); double days3M = fixingEndDate3M.toEpochDay() - FIXING_DATE.toEpochDay(); //nb days in 3M fixing period double days6M = fixingEndDate6M.toEpochDay() - FIXING_DATE.toEpochDay(); //nb days in 6M fixing period double daysCpn = ACCRUAL_END_DATE.toEpochDay() - FIXING_DATE.toEpochDay(); double weight3M = (days6M - daysCpn) / (days6M - days3M); double weight6M = (daysCpn - days3M) / (days6M - days3M); IborRateSensitivity sens3 = IborRateSensitivity.of(GBP_LIBOR_3M_OBS, weight3M); IborRateSensitivity sens6 = IborRateSensitivity.of(GBP_LIBOR_6M_OBS, weight6M); PointSensitivities expected = PointSensitivities.of(ImmutableList.of(sens3, sens6)); PointSensitivityBuilder test = obsFn.rateSensitivity(ro, ACCRUAL_START_DATE, ACCRUAL_END_DATE, mockProv); assertEquals(test.build(), expected); }
public void test_rate_onValuation_noFixing() { DiscountIborIndexRates test = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES_EMPTY); LocalDate startDate = GBP_LIBOR_3M_VAL.getEffectiveDate(); LocalDate endDate = GBP_LIBOR_3M_VAL.getMaturityDate(); double accrualFactor = GBP_LIBOR_3M_VAL.getYearFraction(); double expected = (DFCURVE.discountFactor(startDate) / DFCURVE.discountFactor(endDate) - 1) / accrualFactor; assertEquals(test.rate(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); assertEquals(test.rateIgnoringFixings(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); }
public void test_of() { IborRateComputation test = IborRateComputation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborIndexObservation obs = IborIndexObservation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); IborRateComputation expected = IborRateComputation.of(obs); assertEquals(test, expected); assertEquals(test.getCurrency(), USD); assertEquals(test.getIndex(), obs.getIndex()); assertEquals(test.getFixingDate(), obs.getFixingDate()); assertEquals(test.getEffectiveDate(), obs.getEffectiveDate()); assertEquals(test.getMaturityDate(), obs.getMaturityDate()); assertEquals(test.getYearFraction(), obs.getYearFraction()); }
/** * Calculates the price sensitivity of the Ibor future product. * <p> * The price sensitivity of the product is the sensitivity of the price to the underlying curves. * * @param future the future * @param ratesProvider the rates provider * @param hwProvider the Hull-White model parameter provider * @return the price curve sensitivity of the product */ public PointSensitivities priceSensitivityRates( ResolvedIborFuture future, RatesProvider ratesProvider, HullWhiteOneFactorPiecewiseConstantParametersProvider hwProvider) { IborIndexObservation obs = future.getIborRate().getObservation(); LocalDate fixingStartDate = obs.getEffectiveDate(); LocalDate fixingEndDate = obs.getMaturityDate(); double convexity = hwProvider.futuresConvexityFactor(future.getLastTradeDate(), fixingStartDate, fixingEndDate); IborRateSensitivity sensi = IborRateSensitivity.of(obs, -convexity); // The sensitivity should be to no currency or currency XXX. To avoid useless conversion, the dimension-less // price sensitivity is reported in the future currency. return PointSensitivities.of(sensi); }
public void test_rateIgnoringFixings_onValuation_fixing() { DiscountIborIndexRates test = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES); LocalDate startDate = GBP_LIBOR_3M_VAL.getEffectiveDate(); LocalDate endDate = GBP_LIBOR_3M_VAL.getMaturityDate(); double accrualFactor = GBP_LIBOR_3M_VAL.getYearFraction(); double expected = (DFCURVE.discountFactor(startDate) / DFCURVE.discountFactor(endDate) - 1) / accrualFactor; assertEquals(test.rateIgnoringFixings(GBP_LIBOR_3M_VAL), expected, TOLERANCE_RATE); }
public void test_rate_afterValuation() { DiscountIborIndexRates test = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES); LocalDate startDate = GBP_LIBOR_3M_AFTER.getEffectiveDate(); LocalDate endDate = GBP_LIBOR_3M_AFTER.getMaturityDate(); double accrualFactor = GBP_LIBOR_3M_AFTER.getYearFraction(); double expected = (DFCURVE.discountFactor(startDate) / DFCURVE.discountFactor(endDate) - 1) / accrualFactor; assertEquals(test.rate(GBP_LIBOR_3M_AFTER), expected, TOLERANCE_RATE); }
/** * Calculates the par rate of the Ibor future product. * <p> * The par rate is given by ({@code 1 - price}). * The par rate of the product is the value on the valuation date. * * @param future the future * @param ratesProvider the rates provider * @param hwProvider the Hull-White model parameter provider * @return the par rate of the product, in decimal form */ public double parRate( ResolvedIborFuture future, RatesProvider ratesProvider, HullWhiteOneFactorPiecewiseConstantParametersProvider hwProvider) { IborIndexObservation obs = future.getIborRate().getObservation(); double forward = ratesProvider.iborIndexRates(future.getIndex()).rate(obs); LocalDate fixingStartDate = obs.getEffectiveDate(); LocalDate fixingEndDate = obs.getMaturityDate(); double fixingYearFraction = obs.getYearFraction(); double convexity = hwProvider.futuresConvexityFactor(future.getLastTradeDate(), fixingStartDate, fixingEndDate); return convexity * forward - (1d - convexity) / fixingYearFraction; }
/** * Calculates the price sensitivity to piecewise constant volatility parameters of the Hull-White model. * * @param future the future * @param ratesProvider the rates provider * @param hwProvider the Hull-White model parameter provider * @return the price parameter sensitivity of the product */ public DoubleArray priceSensitivityModelParamsHullWhite( ResolvedIborFuture future, RatesProvider ratesProvider, HullWhiteOneFactorPiecewiseConstantParametersProvider hwProvider) { IborIndexObservation obs = future.getIborRate().getObservation(); double forward = ratesProvider.iborIndexRates(future.getIndex()).rate(obs); LocalDate fixingStartDate = obs.getEffectiveDate(); LocalDate fixingEndDate = obs.getMaturityDate(); double fixingYearFraction = obs.getYearFraction(); DoubleArray convexityDeriv = hwProvider.futuresConvexityFactorAdjoint( future.getLastTradeDate(), fixingStartDate, fixingEndDate).getDerivatives(); convexityDeriv = convexityDeriv.multipliedBy(-forward - 1d / fixingYearFraction); return convexityDeriv; } }
child.put(ExplainKey.INDEX, observation.getIndex()); child.put(ExplainKey.FORWARD_RATE_START_DATE, observation.getEffectiveDate()); child.put(ExplainKey.FORWARD_RATE_END_DATE, observation.getMaturityDate()); child.put(ExplainKey.INDEX_VALUE, rate); if (fixingDate.isBefore(getValuationDate()) ||
@Override public CurrencyParameterSensitivities parameterSensitivity(IborRateSensitivity pointSensitivity) { LocalDate fixingStartDate = pointSensitivity.getObservation().getEffectiveDate(); LocalDate fixingEndDate = pointSensitivity.getObservation().getMaturityDate(); double accrualFactor = pointSensitivity.getObservation().getYearFraction(); double forwardBar = pointSensitivity.getSensitivity(); double dfForwardStart = discountFactors.discountFactor(fixingStartDate); double dfForwardEnd = discountFactors.discountFactor(fixingEndDate); double dfStartBar = forwardBar / (accrualFactor * dfForwardEnd); double dfEndBar = -forwardBar * dfForwardStart / (accrualFactor * dfForwardEnd * dfForwardEnd); ZeroRateSensitivity zrsStart = discountFactors.zeroRatePointSensitivity(fixingStartDate, pointSensitivity.getCurrency()); ZeroRateSensitivity zrsEnd = discountFactors.zeroRatePointSensitivity(fixingEndDate, pointSensitivity.getCurrency()); CurrencyParameterSensitivities psStart = discountFactors.parameterSensitivity(zrsStart).multipliedBy(dfStartBar); CurrencyParameterSensitivities psEnd = discountFactors.parameterSensitivity(zrsEnd).multipliedBy(dfEndBar); return psStart.combinedWith(psEnd); }
public void test_price() { double computed = PRICER.price(FUTURE, RATE_PROVIDER, HW_PROVIDER); LocalDate start = FUTURE.getIborRate().getObservation().getEffectiveDate(); LocalDate end = FUTURE.getIborRate().getObservation().getMaturityDate(); double fixingYearFraction = FUTURE.getIborRate().getObservation().getYearFraction(); double convexity = HW_PROVIDER.futuresConvexityFactor(FUTURE.getLastTradeDate(), start, end); double forward = RATE_PROVIDER.iborIndexRates(EUR_EURIBOR_3M).rate(FUTURE.getIborRate().getObservation()); double expected = 1d - convexity * forward + (1d - convexity) / fixingYearFraction; assertEquals(computed, expected, TOL); }