/** * Gets the Overnight index that the sensitivity refers to. * * @return the Overnight index */ public OvernightIndex getIndex() { return observation.getIndex(); }
private static double approximatedInterest( OvernightIndexObservation observation, LocalDate endDate, OvernightIndexRates rates) { DayCount dayCount = observation.getIndex().getDayCount(); double remainingFixingAccrualFactor = dayCount.yearFraction(observation.getEffectiveDate(), endDate); double forwardRate = rates.periodRate(observation, endDate); return Math.log(1.0 + forwardRate * remainingFixingAccrualFactor); }
/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(OvernightIndexObservation beanToCopy) { this.index = beanToCopy.getIndex(); this.fixingDate = beanToCopy.getFixingDate(); this.publicationDate = beanToCopy.getPublicationDate(); this.effectiveDate = beanToCopy.getEffectiveDate(); this.maturityDate = beanToCopy.getMaturityDate(); this.yearFraction = beanToCopy.getYearFraction(); }
@Override public double periodRate(OvernightIndexObservation startDateObservation, LocalDate endDate) { LocalDate effectiveDate = startDateObservation.getEffectiveDate(); ArgChecker.inOrderNotEqual(effectiveDate, endDate, "startDate", "endDate"); double accrualFactor = startDateObservation.getIndex().getDayCount().yearFraction(effectiveDate, endDate); return simplyCompoundForwardRate(effectiveDate, endDate, accrualFactor); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 100346066: // index return ((OvernightIndexObservation) bean).getIndex(); case 1255202043: // fixingDate return ((OvernightIndexObservation) bean).getFixingDate(); case 1470566394: // publicationDate return ((OvernightIndexObservation) bean).getPublicationDate(); case -930389515: // effectiveDate return ((OvernightIndexObservation) bean).getEffectiveDate(); case -414641441: // maturityDate return ((OvernightIndexObservation) bean).getMaturityDate(); case -1731780257: // yearFraction return ((OvernightIndexObservation) bean).getYearFraction(); } return super.propertyGet(bean, propertyName, quiet); }
private static PointSensitivityBuilder approximatedInterestSensitivity( OvernightIndexObservation observation, LocalDate endDate, OvernightIndexRates rates) { DayCount dayCount = observation.getIndex().getDayCount(); double remainingFixingAccrualFactor = dayCount.yearFraction(observation.getEffectiveDate(), endDate); double forwardRate = rates.periodRate(observation, endDate); PointSensitivityBuilder forwardRateSensitivity = rates.periodRatePointSensitivity(observation, endDate); double rateExp = 1.0 + forwardRate * remainingFixingAccrualFactor; forwardRateSensitivity = forwardRateSensitivity.multipliedBy(remainingFixingAccrualFactor / rateExp); return forwardRateSensitivity; }
public void test_of() { OvernightIndexObservation test = OvernightIndexObservation.of(GBP_SONIA, FIXING_DATE, REF_DATA); assertEquals(test.getIndex(), GBP_SONIA); assertEquals(test.getFixingDate(), FIXING_DATE); assertEquals(test.getPublicationDate(), PUBLICATION_DATE); assertEquals(test.getEffectiveDate(), EFFECTIVE_DATE); assertEquals(test.getMaturityDate(), MATURITY_DATE); assertEquals(test.getCurrency(), GBP_SONIA.getCurrency()); assertEquals(test.toString(), "OvernightIndexObservation[GBP-SONIA on 2016-02-22]"); }
OvernightIndexObservation indexObs = OvernightIndexObservation.of(obsArray[0].getIndex(), periodStartDate, REF_DATA); when(mockRatesPeriodUp.periodRate(indexObs, periodEndDate)).thenReturn(rateCmp + EPS_FD); when(mockRatesPeriodDw.periodRate(indexObs, periodEndDate)).thenReturn(rateCmp - EPS_FD);