Class ImmutableFxIndex

  • All Implemented Interfaces:
    FxIndex, Index, Named, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class ImmutableFxIndex
    extends Object
    implements FxIndex, org.joda.beans.ImmutableBean, Serializable
    A foreign exchange index implementation based on an immutable set of rules.

    A standard immutable implementation of FxIndex that defines the currency pair and the rule for converting from fixing to maturity.

    In most cases, applications should refer to indices by name, using FxIndex.of(String). The named index will typically be resolved to an instance of this class. As such, it is recommended to use the FxIndex interface in application code rather than directly referring to this class.

    See Also:
    Serialized Form
    • Method Detail

      • calculateMaturityFromFixing

        public LocalDate calculateMaturityFromFixing​(LocalDate fixingDate,
                                                     ReferenceData refData)
        Description copied from interface: FxIndex
        Calculates the maturity date from the fixing date.

        The fixing date is the date on which the index is to be observed. The maturity date is the date on which the implied amount is delivered/exchanged. The maturity date is typically two days after the fixing date.

        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.

        The maturity date is also known as the value date.

        Specified by:
        calculateMaturityFromFixing in interface FxIndex
        Parameters:
        fixingDate - the fixing date
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        the maturity date
      • calculateFixingFromMaturity

        public LocalDate calculateFixingFromMaturity​(LocalDate maturityDate,
                                                     ReferenceData refData)
        Description copied from interface: FxIndex
        Calculates the fixing date from the maturity date.

        The fixing date is the date on which the index is to be observed. The maturity date is the date on which the implied amount is delivered/exchanged. The maturity date is typically two days after the fixing date.

        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.

        The maturity date is also known as the value date.

        Specified by:
        calculateFixingFromMaturity in interface FxIndex
        Parameters:
        maturityDate - the maturity date
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        the fixing date
      • resolve

        public Function<LocalDate,​FxIndexObservation> resolve​(ReferenceData refData)
        Description copied from interface: FxIndex
        Resolves this index using the specified reference data, returning a function.

        This returns a Function that converts fixing dates to observations. It binds the holiday calendar, looked up from the reference data, into the result. As such, there is no need to pass the reference data in again.

        This method is intended for use when looping to create multiple instances of FxIndexObservation. Implementations of the method are intended to optimize, avoiding repeated calls to resolve the holiday calendar

        Specified by:
        resolve in interface FxIndex
        Parameters:
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        a function that converts fixing date to observation
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Returns the name of the index.
        Overrides:
        toString in class Object
        Returns:
        the name of the index
      • meta

        public static ImmutableFxIndex.Meta meta()
        The meta-bean for ImmutableFxIndex.
        Returns:
        the meta-bean, not null
      • builder

        public static ImmutableFxIndex.Builder builder()
        Returns a builder used to create an instance of the bean.
        Returns:
        the builder, not null
      • metaBean

        public ImmutableFxIndex.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getName

        public String getName()
        Gets the index name, such as 'EUR/GBP-ECB'.
        Specified by:
        getName in interface FxIndex
        Specified by:
        getName in interface Index
        Specified by:
        getName in interface Named
        Returns:
        the value of the property, not null
      • getCurrencyPair

        public CurrencyPair getCurrencyPair()
        Gets the currency pair.

        An index defines an FX rate in a single direction, such as from EUR to USD. This currency pair defines that direction.

        In most cases, the same index can be used to convert in both directions by taking the rate or the reciprocal as necessary.

        Specified by:
        getCurrencyPair in interface FxIndex
        Returns:
        the value of the property, not null
      • getFixingCalendar

        public HolidayCalendarId getFixingCalendar()
        Gets the calendar that determines which dates are fixing dates.

        The fixing date is when the rate is determined.

        Specified by:
        getFixingCalendar in interface FxIndex
        Returns:
        the value of the property, not null
      • getFixingDateOffset

        public DaysAdjustment getFixingDateOffset()
        Gets the adjustment applied to the maturity date to obtain the fixing date.

        The maturity date is the start date of the indexed deposit. In most cases, the fixing date is 2 days before the maturity date.

        Specified by:
        getFixingDateOffset in interface FxIndex
        Returns:
        the value of the property, not null
      • getMaturityDateOffset

        public DaysAdjustment getMaturityDateOffset()
        Gets the adjustment applied to the fixing date to obtain the maturity date.

        The maturity date is the start date of the indexed deposit. In most cases, the maturity date is 2 days after the fixing date.

        Specified by:
        getMaturityDateOffset in interface FxIndex
        Returns:
        the value of the property, not null
      • toBuilder

        public ImmutableFxIndex.Builder toBuilder()
        Returns a builder that allows this bean to be mutated.
        Returns:
        the mutable builder, not null