Interface FxIndex

  • All Superinterfaces:
    Index, Named
    All Known Implementing Classes:
    ImmutableFxIndex

    public interface FxIndex
    extends Index, Named
    An index of foreign exchange rates.

    An FX rate is the conversion rate between two currencies. An FX index is the rate as published by a specific organization, typically at a well-known time-of-day.

    The index is defined by two dates. The fixing date is the date on which the index is to be observed. The maturity date is the date on which delivery of the implied exchange occurs.

    The most common implementations are provided in FxIndices.

    All implementations of this interface must be immutable and thread-safe.

    • Method Detail

      • of

        static FxIndex of​(String uniqueName)
        Obtains an instance from the specified unique name.

        If the unique name can be parsed as a currency pair, an FX index will be looked up on the pair.

        Parameters:
        uniqueName - the unique name
        Returns:
        the index
        Throws:
        IllegalArgumentException - if the name is not known
      • of

        static FxIndex of​(CurrencyPair currencyPair)
        Obtains an instance from the specified currency pair.

        If a currency pair does not have an implementation, an FX index will be created.

        Parameters:
        currencyPair - the currency pair
        Returns:
        the index
      • createFxIndex

        static FxIndex createFxIndex​(CurrencyPair currencyPair)
        Creates a FX index for the provided currency pair.

        The FX index will be default to the combined holiday calendars for the currency pair. The maturity day offset will default to 2 days.

        Parameters:
        currencyPair - the currency pair
        Returns:
        the index
      • extendedEnum

        static ExtendedEnum<FxIndex> extendedEnum()
        Gets the extended enum helper.

        This helper allows instances of the index to be looked up. It also provides the complete set of available instances.

        Returns:
        the extended enum helper
      • getCurrencyPair

        CurrencyPair getCurrencyPair()
        Gets the currency pair of the index.
        Returns:
        the currency pair of the index
      • getFixingDateOffset

        DaysAdjustment getFixingDateOffset()
        Gets the adjustment applied to the maturity date to obtain 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 business days after the fixing date.

        Returns:
        the fixing date offset
      • getMaturityDateOffset

        DaysAdjustment getMaturityDateOffset()
        Gets the adjustment applied to the fixing date to obtain 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 business days after the fixing date.

        Returns:
        the maturity date offset
      • getFixingCalendar

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

        The rate will be fixed on each business day in this calendar.

        Returns:
        the calendar used to determine the fixing dates of the index
      • calculateMaturityFromFixing

        LocalDate calculateMaturityFromFixing​(LocalDate fixingDate,
                                              ReferenceData refData)
        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.

        Parameters:
        fixingDate - the fixing date
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        the maturity date
      • calculateFixingFromMaturity

        LocalDate calculateFixingFromMaturity​(LocalDate maturityDate,
                                              ReferenceData refData)
        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.

        Parameters:
        maturityDate - the maturity date
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        the fixing date
      • resolve

        Function<LocalDate,​FxIndexObservation> resolve​(ReferenceData refData)
        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

        Parameters:
        refData - the reference data, used to resolve the holiday calendar
        Returns:
        a function that converts fixing date to observation
      • getName

        String getName()
        Gets the name that uniquely identifies this index.

        This name is used in serialization and can be parsed using of(String).

        Specified by:
        getName in interface Index
        Specified by:
        getName in interface Named
        Returns:
        the unique name