Class ImmutableRatesProvider
- java.lang.Object
-
- com.opengamma.strata.pricer.rate.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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableRatesProvider.MetaThe meta-bean forImmutableRatesProvider.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableRatesProviderBuilderbuilder(LocalDate valuationDate)Creates a builder specifying the valuation date.static ImmutableRatesProvidercombined(FxRateProvider fx, ImmutableRatesProvider... providers)Combines a number of rates providers.ImmutableRatesProvidercombinedWith(ImmutableRatesProvider other, FxRateProvider fxProvider)Combines this provider with another.<T> Tdata(MarketDataId<T> id)Gets market data of a specific type.DiscountFactorsdiscountFactors(Currency currency)Gets the discount factors for a currency.booleanequals(Object obj)<T> Optional<T>findData(MarketDataName<T> name)Finds the market data with the specified name.FxForwardRatesfxForwardRates(CurrencyPair currencyPair)Gets the forward FX rates for a currency pair.FxIndexRatesfxIndexRates(FxIndex index)Gets the rates for an FX index.doublefxRate(Currency baseCurrency, Currency counterCurrency)Gets the FX rate for the specified currency pair on the valuation date.Map<CurveName,Curve>getCurves()Returns a map containing all the curves, keyed by curve name.Map<CurveId,Curve>getCurves(CurveGroupName groupName)Returns a map containing all the curves, keyed by curve identifier.ImmutableSet<Currency>getDiscountCurrencies()Gets the set of currencies that discount factors are provided for.ImmutableMap<Currency,Curve>getDiscountCurves()Gets the discount curves, defaulted to an empty map.FxRateProvidergetFxRateProvider()Gets the provider of foreign exchange rates.ImmutableSet<IborIndex>getIborIndices()Gets the set of Ibor indices that are available.ImmutableMap<Index,Curve>getIndexCurves()Gets the forward curves, defaulted to an empty map.ImmutableSet<OvernightIndex>getOvernightIndices()Gets the set of Overnight indices that are available.ImmutableSet<PriceIndex>getPriceIndices()Gets the set of Price indices that are available.ImmutableMap<Index,LocalDateDoubleTimeSeries>getTimeSeries()Gets the time-series, defaulted to an empty map.ImmutableSet<Index>getTimeSeriesIndices()Gets the set of indices that have time-series available.LocalDategetValuationDate()Gets the valuation date.inthashCode()IborIndexRatesiborIndexRates(IborIndex index)Gets the rates for an Ibor index.Stream<Index>indices()Gets the forward indices that are available.static ImmutableRatesProvider.Metameta()The meta-bean forImmutableRatesProvider.ImmutableRatesProvider.MetametaBean()OvernightIndexRatesovernightIndexRates(OvernightIndex index)Gets the rates for an Overnight index.PriceIndexValuespriceIndexValues(PriceIndex index)Gets the values for an Price index.LocalDateDoubleTimeSeriestimeSeries(Index index)Gets the time series.ImmutableRatesProviderBuildertoBuilder()Converts this instance to a builder allowing changes to be made.ImmutableRatesProvidertoImmutableRatesProvider()Converts this provider to an equivalentImmutableRatesProvider.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.pricer.BaseProvider
discountFactor, fxRate
-
Methods inherited from interface com.opengamma.strata.basics.currency.FxRateProvider
convert, convert
-
Methods inherited from interface com.opengamma.strata.pricer.rate.RatesProvider
currencyExposure, parameterSensitivity
-
-
-
-
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
IllegalAccessExceptionis 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 providerproviders- 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
-
getDiscountCurrencies
public ImmutableSet<Currency> getDiscountCurrencies()
Description copied from interface:BaseProviderGets the set of currencies that discount factors are provided for.- Specified by:
getDiscountCurrenciesin interfaceBaseProvider- Returns:
- the set of discount curve currencies
-
indices
public Stream<Index> indices()
Description copied from interface:RatesProviderGets 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:
indicesin interfaceRatesProvider- Returns:
- the indices
-
getIborIndices
public ImmutableSet<IborIndex> getIborIndices()
Description copied from interface:RatesProviderGets the set of Ibor indices that are available.If an index is present in the result of this method, then
RatesProvider.iborIndexRates(IborIndex)should not throw an exception.- Specified by:
getIborIndicesin interfaceRatesProvider- Returns:
- the set of Ibor indices
-
getOvernightIndices
public ImmutableSet<OvernightIndex> getOvernightIndices()
Description copied from interface:RatesProviderGets the set of Overnight indices that are available.If an index is present in the result of this method, then
RatesProvider.overnightIndexRates(OvernightIndex)should not throw an exception.- Specified by:
getOvernightIndicesin interfaceRatesProvider- Returns:
- the set of Overnight indices
-
getPriceIndices
public ImmutableSet<PriceIndex> getPriceIndices()
Description copied from interface:RatesProviderGets the set of Price indices that are available.If an index is present in the result of this method, then
RatesProvider.priceIndexValues(PriceIndex)should not throw an exception.- Specified by:
getPriceIndicesin interfaceRatesProvider- Returns:
- the set of Price indices
-
getTimeSeriesIndices
public ImmutableSet<Index> getTimeSeriesIndices()
Description copied from interface:RatesProviderGets 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:
getTimeSeriesIndicesin interfaceRatesProvider- Returns:
- the set of indices with time-series
-
findData
public <T> Optional<T> findData(MarketDataName<T> name)
Description copied from interface:RatesProviderFinds the market data with the specified name.This is most commonly used to find a
Curveusing aCurveName. If the market data cannot be found, empty is returned.- Specified by:
findDatain interfaceRatesProvider- 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:BaseProviderGets 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:
datain interfaceBaseProvider- Type Parameters:
T- the type of the value- Parameters:
id- the identifier to find- Returns:
- the data associated with the key
-
timeSeries
public LocalDateDoubleTimeSeries timeSeries(Index index)
Description copied from interface:RatesProviderGets the time series.This returns time series for the index.
- Specified by:
timeSeriesin interfaceRatesProvider- Parameters:
index- the index- Returns:
- the time series, empty if time-series not found
-
fxRate
public double fxRate(Currency baseCurrency, Currency counterCurrency)
Description copied from interface:BaseProviderGets 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:
fxRatein interfaceBaseProvider- Specified by:
fxRatein interfaceFxRateProvider- Parameters:
baseCurrency- the base currency, to convert fromcounterCurrency- 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:BaseProviderGets 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:
discountFactorsin interfaceBaseProvider- 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:RatesProviderGets 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:
fxIndexRatesin interfaceRatesProvider- 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:RatesProviderGets 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:
fxForwardRatesin interfaceRatesProvider- 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:RatesProviderGets 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:
iborIndexRatesin interfaceRatesProvider- 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:RatesProviderGets 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:
overnightIndexRatesin interfaceRatesProvider- 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:RatesProviderGets 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:
priceIndexValuesin interfaceRatesProvider- 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
IllegalAccessExceptionis thrown. No attempt is made to combine the FX providers, instead one is supplied.- Parameters:
other- the other rates providerfxProvider- the FX rate provider to use- Returns:
- the combined provider
-
toImmutableRatesProvider
public ImmutableRatesProvider toImmutableRatesProvider()
Description copied from interface:RatesProviderConverts this provider to an equivalentImmutableRatesProvider.- Specified by:
toImmutableRatesProviderin interfaceRatesProvider- Returns:
- the equivalent immutable rates 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.
-
meta
public static ImmutableRatesProvider.Meta meta()
The meta-bean forImmutableRatesProvider.- Returns:
- the meta-bean, not null
-
metaBean
public ImmutableRatesProvider.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getValuationDate
public LocalDate getValuationDate()
Gets the valuation date. All curves and other data items in this provider are calibrated for this date.- Specified by:
getValuationDatein interfaceBaseProvider- 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
-
-