Class DiscountFxForwardRates
- java.lang.Object
-
- com.opengamma.strata.pricer.fx.DiscountFxForwardRates
-
- All Implemented Interfaces:
MarketDataView
,ParameterizedData
,FxForwardRates
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class DiscountFxForwardRates extends Object implements FxForwardRates, org.joda.beans.ImmutableBean, Serializable
Provides access to discount factors for currencies.This provides discount factors for a single currency pair.
This implementation is based on two underlying
DiscountFactors
objects, one for each currency, and anFxRateProvider
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DiscountFxForwardRates.Meta
The meta-bean forDiscountFxForwardRates
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MultiCurrencyAmount
currencyExposure(FxForwardSensitivity pointSensitivity)
Calculates the currency exposure from the point sensitivity.boolean
equals(Object obj)
<T> Optional<T>
findData(MarketDataName<T> name)
Finds the market data with the specified name.DiscountFactors
getBaseCurrencyDiscountFactors()
Gets the discount factors for the base currency of the currency pair.DiscountFactors
getCounterCurrencyDiscountFactors()
Gets the discount factors for the counter currency of the currency pair.CurrencyPair
getCurrencyPair()
Gets the currency pair that the rates are for.FxRateProvider
getFxRateProvider()
Gets the provider of FX rates.double
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.int
getParameterCount()
Gets the number of parameters.ParameterMetadata
getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.LocalDate
getValuationDate()
Gets the valuation date.int
hashCode()
static DiscountFxForwardRates.Meta
meta()
The meta-bean forDiscountFxForwardRates
.DiscountFxForwardRates.Meta
metaBean()
static DiscountFxForwardRates
of(CurrencyPair currencyPair, FxRateProvider fxRateProvider, DiscountFactors baseCurrencyFactors, DiscountFactors counterCurrencyFactors)
Obtains an instance based on two discount factors, one for each currency.CurrencyParameterSensitivities
parameterSensitivity(FxForwardSensitivity pointSensitivity)
Calculates the parameter sensitivity from the point sensitivity.double
rate(Currency baseCurrency, LocalDate referenceDate)
Gets the forward rate at the specified payment date.double
rateFxSpotSensitivity(Currency baseCurrency, LocalDate referenceDate)
Calculates the sensitivity of the forward rate to the current FX rate.PointSensitivityBuilder
ratePointSensitivity(Currency baseCurrency, LocalDate referenceDate)
Calculates the point sensitivity of the forward rate at the specified payment date.String
toString()
DiscountFxForwardRates
withDiscountFactors(DiscountFactors baseCurrencyFactors, DiscountFactors counterCurrencyFactors)
Returns a new instance with different discount factors.DiscountFxForwardRates
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.DiscountFxForwardRates
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.param.ParameterizedData
findParameterIndex
-
-
-
-
Method Detail
-
of
public static DiscountFxForwardRates of(CurrencyPair currencyPair, FxRateProvider fxRateProvider, DiscountFactors baseCurrencyFactors, DiscountFactors counterCurrencyFactors)
Obtains an instance based on two discount factors, one for each currency.The instance is based on the discount factors for each currency.
- Parameters:
currencyPair
- the currency pairfxRateProvider
- the provider of FX ratesbaseCurrencyFactors
- the discount factors in the base currency of the indexcounterCurrencyFactors
- the discount factors in the counter currency of the index- Returns:
- the rates instance
-
getValuationDate
public LocalDate getValuationDate()
Description copied from interface:FxForwardRates
Gets the valuation date.The raw data in this provider is calibrated for this date.
- Specified by:
getValuationDate
in interfaceFxForwardRates
- Specified by:
getValuationDate
in interfaceMarketDataView
- Returns:
- the valuation date
-
findData
public <T> Optional<T> findData(MarketDataName<T> name)
Description copied from interface:MarketDataView
Finds the market data with the specified name.This is most commonly used to find an underlying curve or surface by name. If the market data cannot be found, empty is returned.
- Specified by:
findData
in interfaceMarketDataView
- 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
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedData
Gets the number of parameters.This returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
- Specified by:
getParameterCount
in interfaceParameterizedData
- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedData
Gets the value of the parameter at the specified index.- Specified by:
getParameter
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
getParameterMetadata
public ParameterMetadata getParameterMetadata(int parameterIndex)
Description copied from interface:ParameterizedData
Gets the metadata of the parameter at the specified index.If there is no specific parameter metadata, an empty instance will be returned.
- Specified by:
getParameterMetadata
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
-
withParameter
public DiscountFxForwardRates withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedData
Returns a copy of the data with the value at the specified index altered.This instance is immutable and unaffected by this method call.
- Specified by:
withParameter
in interfaceFxForwardRates
- Specified by:
withParameter
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to getnewValue
- the new value for the specified parameter- Returns:
- a parameterized data instance based on this with the specified parameter altered
-
withPerturbation
public DiscountFxForwardRates withPerturbation(ParameterPerturbation perturbation)
Description copied from interface:ParameterizedData
Returns a perturbed copy of the data.The perturbation instance will be invoked once for each parameter in this instance, returning the perturbed value for that parameter. The result of this method is a new instance that is based on those perturbed values.
This instance is immutable and unaffected by this method call.
- Specified by:
withPerturbation
in interfaceFxForwardRates
- Specified by:
withPerturbation
in interfaceParameterizedData
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
rate
public double rate(Currency baseCurrency, LocalDate referenceDate)
Description copied from interface:FxForwardRates
Gets the forward rate at the specified payment date.The exchange rate of the currency pair varies over time. This method obtains the estimated rate for the payment date.
This method specifies which of the two currencies in the currency pair is to be treated as the base currency for the purposes of the returned rate. If the specified base currency equals the base currency of the currency pair, then the rate is simply returned. If the specified base currency equals the counter currency of the currency pair, then the inverse rate is returned. As such, an amount in the specified base currency can be directly multiplied by the returned FX rate to perform FX conversion.
To convert an amount in the specified base currency to the other currency, multiply it by the returned FX rate.
- Specified by:
rate
in interfaceFxForwardRates
- Parameters:
baseCurrency
- the base currency that the rate should be expressed againstreferenceDate
- the date to query the rate for- Returns:
- the forward rate of the currency pair
-
ratePointSensitivity
public PointSensitivityBuilder ratePointSensitivity(Currency baseCurrency, LocalDate referenceDate)
Description copied from interface:FxForwardRates
Calculates the point sensitivity of the forward rate at the specified payment date.This returns a sensitivity instance referring to the points that were queried in the market data. The sensitivity refers to the result of
FxForwardRates.rate(Currency, LocalDate)
.- Specified by:
ratePointSensitivity
in interfaceFxForwardRates
- Parameters:
baseCurrency
- the base currency that the rate should be expressed againstreferenceDate
- the date to find the sensitivity for- Returns:
- the point sensitivity of the rate
-
rateFxSpotSensitivity
public double rateFxSpotSensitivity(Currency baseCurrency, LocalDate referenceDate)
Description copied from interface:FxForwardRates
Calculates the sensitivity of the forward rate to the current FX rate.This returns the sensitivity to the current FX rate that was used to determine the FX forward rate. The sensitivity refers to the result of
FxForwardRates.rate(Currency, LocalDate)
.- Specified by:
rateFxSpotSensitivity
in interfaceFxForwardRates
- Parameters:
baseCurrency
- the base currency that the rate should be expressed againstreferenceDate
- the date to find the sensitivity for- Returns:
- the sensitivity of the FX forward rate to the current FX rate
-
parameterSensitivity
public CurrencyParameterSensitivities parameterSensitivity(FxForwardSensitivity pointSensitivity)
Description copied from interface:FxForwardRates
Calculates the parameter sensitivity from the point sensitivity.This is used to convert a single point sensitivity to parameter sensitivity.
- Specified by:
parameterSensitivity
in interfaceFxForwardRates
- Parameters:
pointSensitivity
- the point sensitivity to convert- Returns:
- the parameter sensitivity
-
currencyExposure
public MultiCurrencyAmount currencyExposure(FxForwardSensitivity pointSensitivity)
Description copied from interface:FxForwardRates
Calculates the currency exposure from the point sensitivity.This is used to convert a single point sensitivity to currency exposure.
- Specified by:
currencyExposure
in interfaceFxForwardRates
- Parameters:
pointSensitivity
- the point sensitivity to convert- Returns:
- the currency exposure
-
withDiscountFactors
public DiscountFxForwardRates withDiscountFactors(DiscountFactors baseCurrencyFactors, DiscountFactors counterCurrencyFactors)
Returns a new instance with different discount factors.- Parameters:
baseCurrencyFactors
- the new base currency discount factorscounterCurrencyFactors
- the new counter currency discount factors- Returns:
- the new instance
-
meta
public static DiscountFxForwardRates.Meta meta()
The meta-bean forDiscountFxForwardRates
.- Returns:
- the meta-bean, not null
-
metaBean
public DiscountFxForwardRates.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getCurrencyPair
public CurrencyPair getCurrencyPair()
Gets the currency pair that the rates are for.- Specified by:
getCurrencyPair
in interfaceFxForwardRates
- Returns:
- the value of the property, not null
-
getFxRateProvider
public FxRateProvider getFxRateProvider()
Gets the provider of FX rates.- Returns:
- the value of the property, not null
-
getBaseCurrencyDiscountFactors
public DiscountFactors getBaseCurrencyDiscountFactors()
Gets the discount factors for the base currency of the currency pair.- Returns:
- the value of the property, not null
-
getCounterCurrencyDiscountFactors
public DiscountFactors getCounterCurrencyDiscountFactors()
Gets the discount factors for the counter currency of the currency pair.- Returns:
- the value of the property, not null
-
-