Package com.opengamma.strata.data
Class MarketDataFxRateProvider
- java.lang.Object
-
- com.opengamma.strata.data.MarketDataFxRateProvider
-
- All Implemented Interfaces:
FxRateProvider
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class MarketDataFxRateProvider extends Object implements FxRateProvider, org.joda.beans.ImmutableBean, Serializable
Provides FX rates from market data.This decorates an instance of
MarketData
to provide FX rates.The FX rates provided are obtained via a triangulation process. To find the FX rate for the currency pair AAA/BBB:
- If the rate AAA/BBB is available, return it
- Find the triangulation currency of AAA (TTA), try to return rate from AAA/TTA and TTA/BBB
- Find the triangulation currency of BBB (TTB), try to return rate from AAA/TTB and TTB/BBB
- Find the triangulation currency of AAA (TTA) and BBB (TTB), try to return rate from AAA/TTA, TTA/TTB and TTB/BBB
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
double
fxRate(Currency baseCurrency, Currency counterCurrency)
Gets the FX rate for the specified currency pair.ObservableSource
getFxRatesSource()
Gets the source of market data for FX rates.MarketData
getMarketData()
Gets the market data that provides the FX rates.Optional<Currency>
getTriangulationCurrency()
Gets the triangulation currency to use.int
hashCode()
static org.joda.beans.TypedMetaBean<MarketDataFxRateProvider>
meta()
The meta-bean forMarketDataFxRateProvider
.org.joda.beans.TypedMetaBean<MarketDataFxRateProvider>
metaBean()
static MarketDataFxRateProvider
of(MarketData marketData)
Obtains an instance which takes FX rates from the market data.static MarketDataFxRateProvider
of(MarketData marketData, ObservableSource fxRatesSource)
Obtains an instance which takes FX rates from the market data, specifying the source of FX rates.static MarketDataFxRateProvider
of(MarketData marketData, ObservableSource fxRatesSource, Currency triangulationCurrency)
Obtains an instance which takes FX rates from the market data, specifying the source of FX rates.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.basics.currency.FxRateProvider
convert, convert, fxRate
-
-
-
-
Method Detail
-
of
public static MarketDataFxRateProvider of(MarketData marketData)
Obtains an instance which takes FX rates from the market data.- Parameters:
marketData
- market data used for looking up FX rates- Returns:
- the provider
-
of
public static MarketDataFxRateProvider of(MarketData marketData, ObservableSource fxRatesSource)
Obtains an instance which takes FX rates from the market data, specifying the source of FX rates.The source of FX rates is rarely needed, as most applications only need one set of FX rates.
- Parameters:
marketData
- market data used for looking up FX ratesfxRatesSource
- the source of market data for FX rates- Returns:
- the provider
-
of
public static MarketDataFxRateProvider of(MarketData marketData, ObservableSource fxRatesSource, Currency triangulationCurrency)
Obtains an instance which takes FX rates from the market data, specifying the source of FX rates.The source of FX rates is rarely needed, as most applications only need one set of FX rates.
- Parameters:
marketData
- market data used for looking up FX ratesfxRatesSource
- the source of market data for FX ratestriangulationCurrency
- the triangulation currency to use- Returns:
- the provider
-
fxRate
public double fxRate(Currency baseCurrency, Currency counterCurrency)
Description copied from interface:FxRateProvider
Gets the FX rate for the specified currency pair.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 interfaceFxRateProvider
- Parameters:
baseCurrency
- the base currency, to convert fromcounterCurrency
- the counter currency, to convert to- Returns:
- the FX rate for the currency pair
-
meta
public static org.joda.beans.TypedMetaBean<MarketDataFxRateProvider> meta()
The meta-bean forMarketDataFxRateProvider
.- Returns:
- the meta-bean, not null
-
metaBean
public org.joda.beans.TypedMetaBean<MarketDataFxRateProvider> metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getMarketData
public MarketData getMarketData()
Gets the market data that provides the FX rates.- Returns:
- the value of the property, not null
-
getFxRatesSource
public ObservableSource getFxRatesSource()
Gets the source of market data for FX rates.- Returns:
- the value of the property, not null
-
getTriangulationCurrency
public Optional<Currency> getTriangulationCurrency()
Gets the triangulation currency to use.If specified, this currency is used to triangulate FX rates in preference to the standard approach. This would be useful if all FX rates are supplied relative to a currency other than USD.
- Returns:
- the optional value of the property, not null
-
-