@Override public int compareKey(PointSensitivity other) { if (other instanceof InflationRateSensitivity) { InflationRateSensitivity otherInflation = (InflationRateSensitivity) other; return ComparisonChain.start() .compare(getIndex().toString(), otherInflation.getIndex().toString()) .compare(currency, otherInflation.currency) .compare(observation.getFixingMonth(), otherInflation.observation.getFixingMonth()) .result(); } return getClass().getSimpleName().compareTo(other.getClass().getSimpleName()); }
public void test_of() { PriceIndexObservation test = PriceIndexObservation.of(GB_HICP, FIXING_MONTH); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getFixingMonth(), FIXING_MONTH); assertEquals(test.getCurrency(), GB_HICP.getCurrency()); assertEquals(test.toString(), "PriceIndexObservation[GB-HICP on 2016-02]"); }
@Override public PriceIndexObservation build() { return new PriceIndexObservation( index, fixingMonth); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 100346066: // index return ((PriceIndexObservation) bean).getIndex(); case 265281235: // fixingMonth return ((PriceIndexObservation) bean).getFixingMonth(); } return super.propertyGet(bean, propertyName, quiet); }
/** * Creates an instance from an index, reference start month and reference end month. * * @param index the index * @param referenceStartMonth the reference start month * @param referenceEndMonth the reference end month * @return the inflation rate computation */ public static InflationMonthlyRateComputation of( PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth) { return new InflationMonthlyRateComputation( PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceEndMonth)); }
/** * Gets the Ibor index that the sensitivity refers to. * * @return the Ibor index */ public PriceIndex getIndex() { return observation.getIndex(); }
/** * 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 InflationRateSensitivity of(PriceIndexObservation observation, double sensitivity) { return new InflationRateSensitivity(observation, observation.getCurrency(), sensitivity); }
@ImmutableValidator private void validate() { ArgChecker.isTrue( endObservation.getIndex().equals(endSecondObservation.getIndex()), "Both observations must be for the same index"); ArgChecker.inOrderNotEqual( endObservation.getFixingMonth(), endSecondObservation.getFixingMonth(), "endObservation", "endSecondObservation"); }
/** * Creates an instance from an index, start index value and reference end month. * * @param index the index * @param startIndexValue the start index value * @param referenceEndMonth the reference end month * @return the inflation rate computation */ public static InflationEndMonthRateComputation of( PriceIndex index, double startIndexValue, YearMonth referenceEndMonth) { return new InflationEndMonthRateComputation(startIndexValue, PriceIndexObservation.of(index, referenceEndMonth)); }
/** * Gets the Price index. * * @return the Price index */ public PriceIndex getIndex() { return endObservation.getIndex(); }
public void test_of() { InflationInterpolatedRateComputation test = InflationInterpolatedRateComputation.of( GB_HICP, START_MONTH_FIRST, END_MONTH_FIRST, WEIGHT); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getStartObservation().getFixingMonth(), START_MONTH_FIRST); assertEquals(test.getStartSecondObservation().getFixingMonth(), START_MONTH_SECOND); assertEquals(test.getEndObservation().getFixingMonth(), END_MONTH_FIRST); assertEquals(test.getEndSecondObservation().getFixingMonth(), END_MONTH_SECOND); assertEquals(test.getWeight(), WEIGHT, 1.0e-14); }
@ImmutableValidator private void validate() { ArgChecker.isTrue( startObservation.getIndex().equals(endObservation.getIndex()), "Both observations must be for the same index"); ArgChecker.inOrderNotEqual( startObservation.getFixingMonth(), endObservation.getFixingMonth(), "referenceStartMonth", "referenceEndMonth"); }
/** * Creates an instance from an index, reference start month and reference end month. * <p> * The second start/end observations will be one month later than the start/end month. * * @param index the index * @param referenceStartMonth the reference start month * @param referenceEndMonth the reference end month * @param weight the weight * @return the inflation rate computation */ public static InflationInterpolatedRateComputation of( PriceIndex index, YearMonth referenceStartMonth, YearMonth referenceEndMonth, double weight) { return new InflationInterpolatedRateComputation( PriceIndexObservation.of(index, referenceStartMonth), PriceIndexObservation.of(index, referenceStartMonth.plusMonths(1)), PriceIndexObservation.of(index, referenceEndMonth), PriceIndexObservation.of(index, referenceEndMonth.plusMonths(1)), weight); }
/** * Gets the Price index. * * @return the Price index */ public PriceIndex getIndex() { return endObservation.getIndex(); }
/** * 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 fixingMonth the fixing month * @return the rate observation */ public static PriceIndexObservation of(PriceIndex index, YearMonth fixingMonth) { return new PriceIndexObservation(index, fixingMonth); }
@Override public double value(PriceIndexObservation observation) { YearMonth fixingMonth = observation.getFixingMonth(); // If fixing in the past, check time series and returns the historic month price index if present if (fixingMonth.isBefore(YearMonth.from(valuationDate))) { OptionalDouble fixing = fixings.get(fixingMonth.atEndOfMonth()); if (fixing.isPresent()) { return fixing.getAsDouble(); } } throw new MarketDataNotFoundException("Unable to query forward value for historic index " + index); }
@ImmutableValidator private void validate() { ArgChecker.isTrue( startObservation.getIndex().equals(endObservation.getIndex()), "All observations must be for the same index"); ArgChecker.isTrue( startObservation.getIndex().equals(startSecondObservation.getIndex()), "All observations must be for the same index"); ArgChecker.isTrue( startObservation.getIndex().equals(endSecondObservation.getIndex()), "All observations must be for the same index"); ArgChecker.inOrderNotEqual( startObservation.getFixingMonth(), startSecondObservation.getFixingMonth(), "startObservation", "startSecondObservation"); ArgChecker.inOrderOrEqual( startSecondObservation.getFixingMonth(), endObservation.getFixingMonth(), "startSecondObservation", "endObservation"); ArgChecker.inOrderNotEqual( endObservation.getFixingMonth(), endSecondObservation.getFixingMonth(), "endObservation", "endSecondObservation"); }
/** * Creates an instance from an index, start index value and reference end month. * <p> * The second end observations will be one month later than the end month. * * @param index the index * @param startIndexValue the start index value * @param referenceEndMonth the reference end month * @param weight the weight * @return the inflation rate computation */ public static InflationEndInterpolatedRateComputation of( PriceIndex index, double startIndexValue, YearMonth referenceEndMonth, double weight) { return new InflationEndInterpolatedRateComputation( startIndexValue, PriceIndexObservation.of(index, referenceEndMonth), PriceIndexObservation.of(index, referenceEndMonth.plusMonths(1)), weight); }
/** * Gets the Price index. * * @return the Price index */ public PriceIndex getIndex() { return startObservation.getIndex(); }
public void test_of() { InflationEndInterpolatedRateComputation test = InflationEndInterpolatedRateComputation.of( GB_HICP, START_INDEX, END_MONTH_FIRST, WEIGHT); assertEquals(test.getIndex(), GB_HICP); assertEquals(test.getEndObservation().getFixingMonth(), END_MONTH_FIRST); assertEquals(test.getEndSecondObservation().getFixingMonth(), END_MONTH_SECOND); assertEquals(test.getStartIndexValue(), START_INDEX); assertEquals(test.getWeight(), WEIGHT, 1.0e-14); }