Class ImmutableRatesProvider

  • All Implemented Interfaces:
    FxRateProvider, BaseProvider, RatesProvider, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class ImmutableRatesProvider
    extends Object
    implements RatesProvider, org.joda.beans.ImmutableBean, Serializable
    The default immutable rates provider, used to calculate analytic measures.

    This provides the environmental information against which pricing occurs. This includes FX rates, discount factors and forward curves.

    See Also:
    Serialized Form
    • Method Detail

      • combined

        public static ImmutableRatesProvider combined​(FxRateProvider fx,
                                                      ImmutableRatesProvider... providers)
        Combines a number of rates providers.

        If the two providers have curves or time series for the same currency or index, an IllegalAccessException is thrown. The FxRateProviders is not populated with the given provider; no attempt is done on merging the embedded FX providers.

        Parameters:
        fx - the FX provider for the resulting rate provider
        providers - the rates providers to be merged
        Returns:
        the combined rates provider
      • builder

        public static ImmutableRatesProviderBuilder builder​(LocalDate valuationDate)
        Creates a builder specifying the valuation date.
        Parameters:
        valuationDate - the valuation date
        Returns:
        the builder
      • toBuilder

        public ImmutableRatesProviderBuilder toBuilder()
        Converts this instance to a builder allowing changes to be made.
        Returns:
        the builder
      • indices

        public Stream<Index> indices()
        Description copied from interface: RatesProvider
        Gets the forward indices that are available.

        Normally this will only return Ibor, Overnight and Price indices, however it may return other types of index.

        Specified by:
        indices in interface RatesProvider
        Returns:
        the indices
      • getTimeSeriesIndices

        public ImmutableSet<Index> getTimeSeriesIndices()
        Description copied from interface: RatesProvider
        Gets the set of indices that have time-series available.

        Note that the method RatesProvider.timeSeries(Index) returns an empty time-series when the index is not known, thus this method is useful to determine if there actually is a time-series in the underlying data.

        Specified by:
        getTimeSeriesIndices in interface RatesProvider
        Returns:
        the set of indices with time-series
      • findData

        public <T> Optional<T> findData​(MarketDataName<T> name)
        Description copied from interface: RatesProvider
        Finds the market data with the specified name.

        This is most commonly used to find a Curve using a CurveName. If the market data cannot be found, empty is returned.

        Specified by:
        findData in interface RatesProvider
        Type Parameters:
        T - the type of the market data value
        Parameters:
        name - the name to find
        Returns:
        the market data value, empty if not found
      • data

        public <T> T data​(MarketDataId<T> id)
        Description copied from interface: BaseProvider
        Gets market data of a specific type.

        This is a general purpose mechanism to obtain market data. In general, it is desirable to pass the specific market data needed for pricing into the pricing method. However, in some cases, notably swaps, this is not feasible. It is strongly recommended to clearly state on pricing methods what data is required.

        Specified by:
        data in interface BaseProvider
        Type Parameters:
        T - the type of the value
        Parameters:
        id - the identifier to find
        Returns:
        the data associated with the key
      • fxRate

        public double fxRate​(Currency baseCurrency,
                             Currency counterCurrency)
        Description copied from interface: BaseProvider
        Gets the FX rate for the specified currency pair on the valuation date.

        The rate returned is the rate from the base currency to the counter currency as defined by this formula: (1 * baseCurrency = fxRate * counterCurrency).

        Specified by:
        fxRate in interface BaseProvider
        Specified by:
        fxRate in interface FxRateProvider
        Parameters:
        baseCurrency - the base currency, to convert from
        counterCurrency - the counter currency, to convert to
        Returns:
        the current FX rate for the currency pair
      • discountFactors

        public DiscountFactors discountFactors​(Currency currency)
        Description copied from interface: BaseProvider
        Gets the discount factors for a currency.

        The discount factor represents the time value of money for the specified currency when comparing the valuation date to the specified date.

        If the valuation date is on or after the specified date, the discount factor is 1.

        Specified by:
        discountFactors in interface BaseProvider
        Parameters:
        currency - the currency to get the discount factors for
        Returns:
        the discount factors for the specified currency
      • fxIndexRates

        public FxIndexRates fxIndexRates​(FxIndex index)
        Description copied from interface: RatesProvider
        Gets the rates for an FX index.

        This returns an object that can provide historic and forward rates for the specified index.

        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.

        Specified by:
        fxIndexRates in interface RatesProvider
        Parameters:
        index - the index to find rates for
        Returns:
        the rates for the specified index
      • fxForwardRates

        public FxForwardRates fxForwardRates​(CurrencyPair currencyPair)
        Description copied from interface: RatesProvider
        Gets the forward FX rates for a currency pair.

        This returns an object that can provide forward rates for the specified currency pair. See RatesProvider.fxIndexRates(FxIndex) for forward rates with daily fixings.

        Specified by:
        fxForwardRates in interface RatesProvider
        Parameters:
        currencyPair - the currency pair to find forward rates for
        Returns:
        the forward rates for the specified currency pair
      • iborIndexRates

        public IborIndexRates iborIndexRates​(IborIndex index)
        Description copied from interface: RatesProvider
        Gets the rates for an Ibor index.

        The rate of the Ibor index, such as 'GBP-LIBOR-3M', varies over time. This returns an object that can provide historic and forward rates for the specified index.

        Specified by:
        iborIndexRates in interface RatesProvider
        Parameters:
        index - the index to find rates for
        Returns:
        the rates for the specified index
      • overnightIndexRates

        public OvernightIndexRates overnightIndexRates​(OvernightIndex index)
        Description copied from interface: RatesProvider
        Gets the rates for an Overnight index.

        The rate of the Overnight index, such as 'EUR-EONIA', varies over time. This returns an object that can provide historic and forward rates for the specified index.

        Specified by:
        overnightIndexRates in interface RatesProvider
        Parameters:
        index - the index to find rates for
        Returns:
        the rates for the specified index
      • priceIndexValues

        public PriceIndexValues priceIndexValues​(PriceIndex index)
        Description copied from interface: RatesProvider
        Gets the values for an Price index.

        The value of the Price index, such as 'US-CPI-U', varies over time. This returns an object that can provide historic and forward values for the specified index.

        Specified by:
        priceIndexValues in interface RatesProvider
        Parameters:
        index - the index to find values for
        Returns:
        the values for the specified index
      • combinedWith

        public ImmutableRatesProvider combinedWith​(ImmutableRatesProvider other,
                                                   FxRateProvider fxProvider)
        Combines this provider with another.

        If the two providers have curves or time series for the same currency or index, an IllegalAccessException is thrown. No attempt is made to combine the FX providers, instead one is supplied.

        Parameters:
        other - the other rates provider
        fxProvider - the FX rate provider to use
        Returns:
        the combined provider
      • getCurves

        public Map<CurveName,​Curve> getCurves()
        Returns a map containing all the curves, keyed by curve name.

        No checks are performed to see if one curve name is mapped to two different curves.

        Returns:
        the map of curves
      • getCurves

        public Map<CurveId,​Curve> getCurves​(CurveGroupName groupName)
        Returns a map containing all the curves, keyed by curve identifier.

        No checks are performed to see if one curve name is mapped to two different curves.

        This method is useful when transforming a rates provider to MarketData.

        Parameters:
        groupName - the curve group name
        Returns:
        the map of curves, keyed by CurveId.
      • getValuationDate

        public LocalDate getValuationDate()
        Gets the valuation date. All curves and other data items in this provider are calibrated for this date.
        Specified by:
        getValuationDate in interface BaseProvider
        Returns:
        the value of the property, not null
      • getFxRateProvider

        public FxRateProvider getFxRateProvider()
        Gets the provider of foreign exchange rates. Conversions where both currencies are the same always succeed.
        Returns:
        the value of the property, not null
      • getDiscountCurves

        public ImmutableMap<Currency,​Curve> getDiscountCurves()
        Gets the discount curves, defaulted to an empty map. The curve data, predicting the future, associated with each currency.
        Returns:
        the value of the property, not null
      • getIndexCurves

        public ImmutableMap<Index,​Curve> getIndexCurves()
        Gets the forward curves, defaulted to an empty map. The curve data, predicting the future, associated with each index. This is used for Ibor, Overnight and Price indices.
        Returns:
        the value of the property, not null
      • getTimeSeries

        public ImmutableMap<Index,​LocalDateDoubleTimeSeries> getTimeSeries()
        Gets the time-series, defaulted to an empty map. The historic data associated with each index.
        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object