/** * Gets the effective date. * * @return the effective date */ public LocalDate getEffectiveDate() { return observation.getEffectiveDate(); }
@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); }
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()); }
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 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); }
/** * 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; } }
IborIndexObservation obs = ((IborRateComputation) rateAccrualPeriod.getRateComputation()).getObservation(); IborIndex index = obs.getIndex(); LocalDate fixingStartDate = obs.getEffectiveDate(); double fixingYearFraction = obs.getYearFraction(); double beta = (1d + fixingYearFraction * ratesProvider.iborIndexRates(index).rate(obs)) *
IborIndexObservation obs = ((IborRateComputation) rateAccrualPeriod.getRateComputation()).getObservation(); IborIndex index = obs.getIndex(); LocalDate fixingStartDate = obs.getEffectiveDate(); double fixingYearFraction = obs.getYearFraction();
child.put(ExplainKey.FIXING_DATE, fixingDate); 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);
@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); }