/** * Gets the Overnight index that the future is based on. * * @return the Overnight index */ public OvernightIndex getIndex() { return overnightRate.getIndex(); }
@Override public default void collectIndices(ImmutableSet.Builder<Index> builder) { builder.add(getIndex()); }
@ImmutablePreBuild private static void preBuild(Builder builder) { if (builder.overnightRate != null) { if (builder.currency == null) { builder.currency = builder.overnightRate.getIndex().getCurrency(); } } }
/** * Calculates the effective date from the fixing date. * <p> * The fixing date is the date on which the index is to be observed. * The effective date is the date on which the implied deposit starts. * <p> * No error is thrown if the input date is not a valid fixing date. * Instead, the fixing date is moved to the next valid fixing date and then processed. * * @param fixingDate the fixing date * @return the effective date */ public default LocalDate calculateEffectiveFromFixing(LocalDate fixingDate) { return getFixingCalendar().shift(getFixingCalendar().nextOrSame(fixingDate), getIndex().getEffectiveDateOffset()); }
/** * Calculates the publication date from the fixing date. * <p> * The fixing date is the date on which the index is to be observed. * The publication date is the date on which the fixed rate is actually published. * <p> * No error is thrown if the input date is not a valid fixing date. * Instead, the fixing date is moved to the next valid fixing date and then processed. * * @param fixingDate the fixing date * @return the publication date */ public default LocalDate calculatePublicationFromFixing(LocalDate fixingDate) { return getFixingCalendar().shift(getFixingCalendar().nextOrSame(fixingDate), getIndex().getPublicationDateOffset()); }
/** * Calculates the maturity date from the fixing date. * <p> * The fixing date is the date on which the index is to be observed. * The maturity date is the date on which the implied deposit ends. * <p> * No error is thrown if the input date is not a valid fixing date. * Instead, the fixing date is moved to the next valid fixing date and then processed. * * @param fixingDate the fixing date * @return the maturity date */ public default LocalDate calculateMaturityFromFixing(LocalDate fixingDate) { return getFixingCalendar().shift(getFixingCalendar().nextOrSame(fixingDate), getIndex().getEffectiveDateOffset() + 1); }
/** * Calculates the fixing date from the effective date. * <p> * The fixing date is the date on which the index is to be observed. * The effective date is the date on which the implied deposit starts. * <p> * No error is thrown if the input date is not a valid effective date. * Instead, the effective date is moved to the next valid effective date and then processed. * * @param effectiveDate the effective date * @return the fixing date */ public default LocalDate calculateFixingFromEffective(LocalDate effectiveDate) { return getFixingCalendar().shift(getFixingCalendar().nextOrSame(effectiveDate), -getIndex().getEffectiveDateOffset()); }
/** * Creates an observation object for the specified fixing date. * * @param fixingDate the fixing date * @return the index observation */ public default OvernightIndexObservation observeOn(LocalDate fixingDate) { LocalDate publicationDate = calculatePublicationFromFixing(fixingDate); LocalDate effectiveDate = calculateEffectiveFromFixing(fixingDate); LocalDate maturityDate = calculateMaturityFromEffective(effectiveDate); return OvernightIndexObservation.builder() .index(getIndex()) .fixingDate(fixingDate) .publicationDate(publicationDate) .effectiveDate(effectiveDate) .maturityDate(maturityDate) .yearFraction(getIndex().getDayCount().yearFraction(effectiveDate, maturityDate)) .build(); }