/** * 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(); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(IborAveragedFixing beanToCopy) { this.observation = beanToCopy.getObservation(); this.fixedRate = beanToCopy.fixedRate; this.weight = beanToCopy.getWeight(); }
@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(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 122345516: // observation return ((IborAveragedFixing) bean).getObservation(); case 747425396: // fixedRate return ((IborAveragedFixing) bean).fixedRate; case -791592328: // weight return ((IborAveragedFixing) bean).getWeight(); } return super.propertyGet(bean, propertyName, quiet); }
private PointSensitivityBuilder weightedSensitivity( IborAveragedFixing fixing, double totalWeight, IborIndexRates rates) { return rates.ratePointSensitivity(fixing.getObservation()) .multipliedBy(fixing.getWeight() / totalWeight); }
private double weightedRate(IborAveragedFixing fixing, IborIndexRates rates) { double rate = fixing.getFixedRate().orElse(rates.rate(fixing.getObservation())); return rate * fixing.getWeight(); }
@Override public double explainRate( IborAveragedRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider, ExplainMapBuilder builder) { IborIndexRates rates = provider.iborIndexRates(computation.getIndex()); for (IborAveragedFixing fixing : computation.getFixings()) { rates.explainRate(fixing.getObservation(), builder, child -> child.put(ExplainKey.WEIGHT, fixing.getWeight())); } double rate = rate(computation, startDate, endDate, provider); builder.put(ExplainKey.COMBINED_RATE, rate); return rate; }