public interface ScenarioFxRateProvider
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.
Modifier and Type | Method and Description |
---|---|
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.
|
default double |
fxRate(Currency baseCurrency,
Currency counterCurrency,
int scenarioIndex)
Gets the FX rate for the specified currency pair and scenario index.
|
FxRateProvider |
fxRateProvider(int scenarioIndex)
Gets the FX rate provider for the specified scenario index.
|
int |
getScenarioCount()
Gets the number of scenarios.
|
static ScenarioFxRateProvider |
of(ScenarioMarketData marketData)
Returns a scenario FX rate provider which takes its data from the provided market data.
|
static ScenarioFxRateProvider |
of(ScenarioMarketData marketData,
ObservableSource source)
Returns a scenario FX rate provider which takes its data from the provided market data.
|
static ScenarioFxRateProvider of(ScenarioMarketData marketData)
marketData
- market data containing FX ratesstatic ScenarioFxRateProvider of(ScenarioMarketData marketData, ObservableSource source)
marketData
- market data containing FX ratessource
- the source of the FX ratesint getScenarioCount()
default double convert(double amount, Currency fromCurrency, Currency toCurrency, int scenarioIndex)
amount
- an amount in fromCurrency
fromCurrency
- the currency of the amounttoCurrency
- the currency into which the amount should be convertedscenarioIndex
- the scenario indextoCurrency
IllegalArgumentException
- if either of the currencies aren't included in the currency pair of this ratedefault double fxRate(Currency baseCurrency, Currency counterCurrency, int scenarioIndex)
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.
baseCurrency
- the base currency, to convert fromcounterCurrency
- the counter currency, to convert toscenarioIndex
- the scenario indexRuntimeException
- if no FX rate could be foundFxRateProvider fxRateProvider(int scenarioIndex)
scenarioIndex
- the scenario indexRuntimeException
- if no FX rate could be foundCopyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.