Interface ScenarioFxRateProvider


  • public interface ScenarioFxRateProvider
    A provider of FX rates for scenarios.

    This provides the ability to obtain a set of FX rates, one for each scenario. The interface does not mandate when the rate applies, however it typically represents the current rate.

    This is the multi-scenario version of FxRateProvider.

    Implementations do not have to be immutable, but calls to the methods must be thread-safe.

    • Method Detail

      • of

        static ScenarioFxRateProvider of​(ScenarioMarketData marketData)
        Returns a scenario FX rate provider which takes its data from the provided market data.
        Parameters:
        marketData - market data containing FX rates
        Returns:
        a scenario FX rate provider which takes its data from the provided market data
      • of

        static ScenarioFxRateProvider of​(ScenarioMarketData marketData,
                                         ObservableSource source)
        Returns a scenario FX rate provider which takes its data from the provided market data.
        Parameters:
        marketData - market data containing FX rates
        source - the source of the FX rates
        Returns:
        a scenario FX rate provider which takes its data from the provided market data
      • getScenarioCount

        int getScenarioCount()
        Gets the number of scenarios.
        Returns:
        the number of scenarios
      • convert

        default double convert​(double amount,
                               Currency fromCurrency,
                               Currency toCurrency,
                               int scenarioIndex)
        Converts an amount in a currency to an amount in a different currency using a rate from this provider.
        Parameters:
        amount - an amount in fromCurrency
        fromCurrency - the currency of the amount
        toCurrency - the currency into which the amount should be converted
        scenarioIndex - the scenario index
        Returns:
        the amount converted into toCurrency
        Throws:
        java.lang.IllegalArgumentException - if either of the currencies aren't included in the currency pair of this rate
      • fxRate

        default double fxRate​(Currency baseCurrency,
                              Currency counterCurrency,
                              int scenarioIndex)
        Gets the FX rate for the specified currency pair and scenario index.

        The rate returned is the rate from the base currency to the counter currency as defined by this formula: (1 * baseCurrency = fxRate * counterCurrency). This will return 1 if the two input currencies are the same.

        Parameters:
        baseCurrency - the base currency, to convert from
        counterCurrency - the counter currency, to convert to
        scenarioIndex - the scenario index
        Returns:
        the FX rate for the currency pair
        Throws:
        java.lang.RuntimeException - if no FX rate could be found
      • fxRateProvider

        FxRateProvider fxRateProvider​(int scenarioIndex)
        Gets the FX rate provider for the specified scenario index.
        Parameters:
        scenarioIndex - the scenario index
        Returns:
        the FX rate for the currency pair
        Throws:
        java.lang.RuntimeException - if no FX rate could be found