Interface BaseProvider

  • All Superinterfaces:
    FxRateProvider
    All Known Subinterfaces:
    RatesProvider
    All Known Implementing Classes:
    ImmutableRatesProvider

    public interface BaseProvider
    extends FxRateProvider
    A provider of data used for pricing.

    This provides the valuation date, FX rates and discount factors, Sensitivity for discount factors is also available.

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

    • Method Detail

      • getValuationDate

        java.time.LocalDate getValuationDate()
        Gets the valuation date.

        The raw data in this provider is calibrated for this date.

        Returns:
        the valuation date
      • getDiscountCurrencies

        java.util.Set<Currency> getDiscountCurrencies()
        Gets the set of currencies that discount factors are provided for.
        Returns:
        the set of discount curve currencies
      • data

        <T> T data​(MarketDataId<T> id)
        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.

        Type Parameters:
        T - the type of the value
        Parameters:
        id - the identifier to find
        Returns:
        the data associated with the key
        Throws:
        java.lang.IllegalArgumentException - if the data is not available
      • fxRate

        double fxRate​(Currency baseCurrency,
                      Currency counterCurrency)
        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 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
        Throws:
        java.lang.IllegalArgumentException - if the rate is not available
      • fxRate

        default double fxRate​(CurrencyPair currencyPair)
        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 FxRateProvider
        Parameters:
        currencyPair - the ordered currency pair defining the rate required
        Returns:
        the current FX rate for the currency pair
        Throws:
        java.lang.IllegalArgumentException - if the rate is not available
      • discountFactors

        DiscountFactors discountFactors​(Currency currency)
        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.

        Parameters:
        currency - the currency to get the discount factors for
        Returns:
        the discount factors for the specified currency
        Throws:
        java.lang.IllegalArgumentException - if the discount factors are not available
      • discountFactor

        default double discountFactor​(Currency currency,
                                      java.time.LocalDate date)
        Gets the discount factor applicable 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.

        Parameters:
        currency - the currency to get the discount factor for
        date - the date to discount to
        Returns:
        the discount factor
        Throws:
        java.lang.IllegalArgumentException - if the discount factors are not available