/** * Gets the Ibor index that the sensitivity refers to. * * @return the Ibor index */ public IborIndex getIndex() { return observation.getIndex(); }
/** * Gets the Ibor index. * * @return the index */ public IborIndex getIndex() { return observation.getIndex(); }
/** * Gets the Ibor index. * <p> * The rate to be paid is based on this index * It will be a well known market index such as 'GBP-LIBOR-3M'. * * @return the Ibor index */ public IborIndex getIndex() { return fixings.get(0).getObservation().getIndex(); }
@ImmutableConstructor private IborAveragedRateComputation(List<IborAveragedFixing> fixings) { fixings.stream() .map(f -> f.getObservation().getIndex()) .distinct() .reduce(ensureOnlyOne()); this.fixings = ImmutableList.copyOf(fixings); this.totalWeight = fixings.stream() .mapToDouble(f -> f.getWeight()) .sum(); }
/** * Obtains an instance from the observation and sensitivity value. * <p> * The currency is defaulted from the index. * * @param observation the rate observation, including the fixing date * @param sensitivity the value of the sensitivity * @return the point sensitivity object */ public static IborRateSensitivity of(IborIndexObservation observation, double sensitivity) { return new IborRateSensitivity(observation, observation.getIndex().getCurrency(), sensitivity); }
@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)); } }
@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 double rate( IborInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { IborIndexObservation obs1 = computation.getShortObservation(); IborIndexObservation obs2 = computation.getLongObservation(); IborIndexRates rates1 = provider.iborIndexRates(obs1.getIndex()); IborIndexRates rates2 = provider.iborIndexRates(obs2.getIndex()); double rate1 = rates1.rate(obs1); double rate2 = rates2.rate(obs2); DoublesPair weights = weights(obs1, obs2, endDate); return ((rate1 * weights.getFirst()) + (rate2 * weights.getSecond())) / (weights.getFirst() + weights.getSecond()); }
@Override public double explainRate( IborInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder) { IborIndexObservation obs1 = computation.getShortObservation(); IborIndexObservation obs2 = computation.getLongObservation(); DoublesPair weights = weights(obs1, obs2, endDate); IborIndexRates rates1 = provider.iborIndexRates(obs1.getIndex()); IborIndexRates rates2 = provider.iborIndexRates(obs2.getIndex()); rates1.explainRate(obs1, builder, child -> child.put(ExplainKey.WEIGHT, weights.getFirst())); rates2.explainRate(obs2, builder, child -> child.put(ExplainKey.WEIGHT, weights.getSecond())); double rate = rate(computation, startDate, endDate, provider); builder.put(ExplainKey.COMBINED_RATE, rate); return rate; }
@Override public PointSensitivityBuilder rateSensitivity( IborInterpolatedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { // computes the dates related to the underlying deposits associated to the indices IborIndexObservation obs1 = computation.getShortObservation(); IborIndexObservation obs2 = computation.getLongObservation(); DoublesPair weights = weights(obs1, obs2, endDate); double totalWeight = weights.getFirst() + weights.getSecond(); IborIndexRates ratesIndex1 = provider.iborIndexRates(obs1.getIndex()); PointSensitivityBuilder sens1 = ratesIndex1.ratePointSensitivity(obs1) .multipliedBy(weights.getFirst() / totalWeight); IborIndexRates ratesIndex2 = provider.iborIndexRates(obs2.getIndex()); PointSensitivityBuilder sens2 = ratesIndex2.ratePointSensitivity(obs2) .multipliedBy(weights.getSecond() / totalWeight); return sens1.combinedWith(sens2); }
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()); }
LocalDate paymentDate = ratePaymentPeriod.getPaymentDate(); IborIndexObservation obs = ((IborRateComputation) rateAccrualPeriod.getRateComputation()).getObservation(); IborIndex index = obs.getIndex(); LocalDate fixingStartDate = obs.getEffectiveDate(); double fixingYearFraction = obs.getYearFraction();
LocalDate paymentDate = ratePaymentPeriod.getPaymentDate(); IborIndexObservation obs = ((IborRateComputation) rateAccrualPeriod.getRateComputation()).getObservation(); IborIndex index = obs.getIndex(); LocalDate fixingStartDate = obs.getEffectiveDate(); double fixingYearFraction = obs.getYearFraction();
child.put(ExplainKey.ENTRY_TYPE, "IborIndexObservation"); 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());