@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); }
/** * Creates an instance from an index and fixing date. * <p> * The reference data is used to find the maturity date from the fixing date. * * @param index the index * @param fixingDate the fixing date * @param refData the reference data to use when resolving holiday calendars * @return the rate computation */ public static IborRateComputation of(IborIndex index, LocalDate fixingDate, ReferenceData refData) { return new IborRateComputation(IborIndexObservation.of(index, fixingDate, refData)); }
@Override public IborIndexObservation build() { return new IborIndexObservation( index, fixingDate, effectiveDate, maturityDate, yearFraction); }
@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; }
@ImmutableValidator private void validate() { IborIndex shortIndex = shortObservation.getIndex(); IborIndex longIndex = longObservation.getIndex(); if (!shortIndex.getCurrency().equals(longIndex.getCurrency())) { throw new IllegalArgumentException("Interpolation requires two indices in the same currency"); } if (shortIndex.equals(longIndex)) { throw new IllegalArgumentException("Interpolation requires two different indices"); } if (!shortObservation.getFixingDate().equals(longObservation.getFixingDate())) { throw new IllegalArgumentException("Interpolation requires observations with same fixing date"); } if (!indicesInOrder(shortIndex, longIndex, shortObservation.getFixingDate())) { throw new IllegalArgumentException(Messages.format( "Interpolation indices passed in wrong order: {} {}", shortIndex, longIndex)); } }
/** * Gets the fixing date. * * @return the fixing date */ public LocalDate getFixingDate() { // fixing date is the same for both observations return shortObservation.getFixingDate(); }
LocalDate paymentDate = ratePaymentPeriod.getPaymentDate(); 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)) * ratesProvider.discountFactor(paymentPeriod.getCurrency(), paymentPeriod.getPaymentDate()) /
double discountFactor = Math.exp(-discountRate * paymentTime); LocalDate fixingDate = FRA_NONE.getStartDate(); IborIndexObservation obs = IborIndexObservation.of(FRA.getIndex(), fixingDate, REF_DATA); PointSensitivityBuilder sens = IborRateSensitivity.of(obs, 1d); when(mockDf.discountFactor(fraExp.getPaymentDate())) IborRateSensitivity sensitivity0 = (IborRateSensitivity) sensitivities.get(0); assertEquals(sensitivity0.getIndex(), FRA_NONE.getIndex()); assertEquals(sensitivity0.getObservation().getFixingDate(), fixingDate); assertEquals(sensitivity0.getSensitivity(), fdSense, FRA_NONE.getNotional() * eps); ZeroRateSensitivity sensitivity1 = (ZeroRateSensitivity) sensitivities.get(1);
/** * Gets the maturity date. * * @return the maturity date */ public LocalDate getMaturityDate() { return observation.getMaturityDate(); }
/** * Gets the Ibor index. * * @return the index */ public IborIndex getIndex() { return observation.getIndex(); }
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); }
/** * 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_of() { IborIndexObservation test = IborIndexObservation.of(USD_LIBOR_3M, date(2016, 2, 18), REF_DATA); double yearFraction = USD_LIBOR_3M.getDayCount().yearFraction(date(2016, 2, 22), date(2016, 5, 23)); IborIndexObservation expected = new IborIndexObservation( USD_LIBOR_3M, date(2016, 2, 18), date(2016, 2, 22), date(2016, 5, 23), yearFraction); assertEquals(test, expected); assertEquals(test.getCurrency(), USD); }
/** * Gets the effective date. * * @return the effective date */ public LocalDate getEffectiveDate() { return observation.getEffectiveDate(); }
/** * Gets the year fraction. * * @return the year fraction */ public double getYearFraction() { return observation.getYearFraction(); }
/** * 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; }
/** * Gets the fixing date. * * @return the fixing date */ public LocalDate getFixingDate() { return observation.getFixingDate(); }
LocalDate paymentDate = ratePaymentPeriod.getPaymentDate(); IborIndexObservation obs = ((IborRateComputation) rateAccrualPeriod.getRateComputation()).getObservation(); IborIndex index = obs.getIndex(); LocalDate fixingStartDate = obs.getEffectiveDate(); double fixingYearFraction = obs.getYearFraction();
double discountFactor = Math.exp(-discountRate * paymentTime); LocalDate fixingDate = FRA_AFMA.getStartDate(); IborIndexObservation obs = IborIndexObservation.of(FRA.getIndex(), fixingDate, REF_DATA); PointSensitivityBuilder sens = IborRateSensitivity.of(obs, 1d); when(mockDf.discountFactor(fraExp.getPaymentDate())) IborRateSensitivity sensitivity0 = (IborRateSensitivity) sensitivities.get(0); assertEquals(sensitivity0.getIndex(), FRA_AFMA.getIndex()); assertEquals(sensitivity0.getObservation().getFixingDate(), fixingDate); assertEquals(sensitivity0.getSensitivity(), fdSense, FRA_AFMA.getNotional() * eps); ZeroRateSensitivity sensitivity1 = (ZeroRateSensitivity) sensitivities.get(1);
@Override public double rateIgnoringFixings(IborIndexObservation observation) { double relativeYearFraction = relativeYearFraction(observation.getMaturityDate()); return curve.yValue(relativeYearFraction); }