@Override public double rate( OvernightCompoundedAnnualRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { OvernightIndexRates rates = provider.overnightIndexRates(computation.getIndex()); ForwardOvernightCompoundedAnnualRateComputationFn.ObservationDetails details = new ForwardOvernightCompoundedAnnualRateComputationFn.ObservationDetails(computation, rates); return details.calculateRate(); }
@Override public PointSensitivityBuilder rateSensitivity( OvernightCompoundedAnnualRateComputation computation, LocalDate startDate, LocalDate endDate, RatesProvider provider) { OvernightIndexRates rates = provider.overnightIndexRates(computation.getIndex()); ForwardOvernightCompoundedAnnualRateComputationFn.ObservationDetails details = new ForwardOvernightCompoundedAnnualRateComputationFn.ObservationDetails(computation, rates); return details.calculateRateSensitivity(); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(OvernightCompoundedAnnualRateComputation beanToCopy) { this.index = beanToCopy.getIndex(); this.fixingCalendar = beanToCopy.getFixingCalendar(); this.startDate = beanToCopy.getStartDate(); this.endDate = beanToCopy.getEndDate(); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 100346066: // index return ((OvernightCompoundedAnnualRateComputation) bean).getIndex(); case 394230283: // fixingCalendar return ((OvernightCompoundedAnnualRateComputation) bean).getFixingCalendar(); case -2129778896: // startDate return ((OvernightCompoundedAnnualRateComputation) bean).getStartDate(); case -1607727319: // endDate return ((OvernightCompoundedAnnualRateComputation) bean).getEndDate(); } return super.propertyGet(bean, propertyName, quiet); }
public void test_of() { OvernightCompoundedAnnualRateComputation test = sut(); assertEquals(test.getStartDate(), date(2016, 2, 24)); assertEquals(test.getEndDate(), date(2016, 3, 24)); assertEquals(test.getIndex(), BRL_CDI); assertEquals(test.getFixingCalendar(), BRL_CDI.getFixingCalendar().resolve(REF_DATA)); }
private double pastCompositionFactor() { double compositionFactor = 1.0d; LocalDate currentFixing = firstFixing; LocalDate currentPublication = computation.calculatePublicationFromFixing(currentFixing); while (!(currentFixing.isAfter(lastFixing)) && rates.getValuationDate().isAfter(currentPublication)) { LocalDate effectiveDate = computation.calculateEffectiveFromFixing(currentFixing); LocalDate maturityDate = computation.calculateMaturityFromEffective(effectiveDate); double accrualFactor = dayCount.yearFraction(effectiveDate, maturityDate); double rate = checkedFixing(currentFixing, indexFixingDateSeries, computation.getIndex()); compositionFactor *= Math.pow(1.0d + rate, accrualFactor); currentFixing = computation.getFixingCalendar().next(currentFixing); currentPublication = computation.calculatePublicationFromFixing(currentFixing); } nextFixing = currentFixing; return compositionFactor; }
private ObservationDetails(OvernightCompoundedAnnualRateComputation computation, OvernightIndexRates rates) { this.computation = computation; this.rates = rates; this.indexFixingDateSeries = rates.getFixings(); this.dayCount = computation.getIndex().getDayCount(); this.firstFixing = computation.getStartDate(); this.lastFixingP1 = computation.getEndDate(); this.lastFixing = computation.getFixingCalendar().previous(lastFixingP1); LocalDate startUnderlyingPeriod = computation.calculateEffectiveFromFixing(firstFixing); LocalDate endUnderlyingPeriod = computation.calculateMaturityFromFixing(lastFixing); this.accrualFactorTotal = dayCount.yearFraction(startUnderlyingPeriod, endUnderlyingPeriod); }