public final class CurrencyParameterSensitivities extends Object implements FxConvertible<CurrencyParameterSensitivities>, org.joda.beans.ImmutableBean, Serializable
Parameter sensitivity is the sensitivity of a value to the parameters of
parameterized market data objects that are used to determine the value.
Common ParameterizedData implementations include Curve and Surface.
For example, the parameter sensitivity for present value on a FRA might contain two entries, one for the Ibor forward curve and one for the discount curve. Each entry identifies the curve that was queried and the resulting sensitivity values, one for each node on the curve.
The sensitivity is expressed as a single entry for piece of parameterized market data. The sensitivity represents a monetary value in the specified currency. The order of the list has no specific meaning.
One way of viewing this class is as a Map from a specific sensitivity key to
DoubleArray sensitivity values. However, instead of being structured as a Map,
the data is structured as a List, with the key and value in each entry.
As such, the sensitivities are always in a "normalized" form.
| Modifier and Type | Class and Description |
|---|---|
static class |
CurrencyParameterSensitivities.Meta
The meta-bean for
CurrencyParameterSensitivities. |
| Modifier and Type | Method and Description |
|---|---|
static CurrencyParameterSensitivitiesBuilder |
builder()
Returns a builder that can be used to create an instance of
CurrencyParameterSensitivities. |
CurrencyParameterSensitivities |
combinedWith(CurrencyParameterSensitivities other)
Combines this parameter sensitivities with another instance.
|
CurrencyParameterSensitivities |
combinedWith(CurrencyParameterSensitivity other)
Combines this parameter sensitivities with another instance.
|
CurrencyParameterSensitivities |
convertedTo(Currency resultCurrency,
FxRateProvider rateProvider)
Converts the sensitivities in this instance to an equivalent in the specified currency.
|
static CurrencyParameterSensitivities |
empty()
An empty sensitivity instance.
|
boolean |
equals(Object obj) |
boolean |
equalWithTolerance(CurrencyParameterSensitivities other,
double tolerance)
Checks if this sensitivity equals another within the specified tolerance.
|
Optional<CurrencyParameterSensitivity> |
findSensitivity(MarketDataName<?> name,
Currency currency)
Finds a single sensitivity instance by name and currency.
|
ImmutableList<CurrencyParameterSensitivity> |
getSensitivities()
Gets the parameter sensitivities.
|
CurrencyParameterSensitivity |
getSensitivity(MarketDataName<?> name,
Currency currency)
Gets a single sensitivity instance by name and currency.
|
int |
hashCode() |
CurrencyParameterSensitivities |
mapSensitivities(DoubleUnaryOperator operator)
Returns an instance with the specified operation applied to the sensitivity values.
|
CurrencyParameterSensitivities |
mapSensitivitiesWithIndex(IntDoubleToDoubleFunction function)
Returns an instance with an operation applied to each indexed value in the sensitivity values.
|
CurrencyParameterSensitivities |
mergedWith(CurrencyParameterSensitivities other)
Merges this parameter sensitivities with another instance taking the metadata into account.
|
static CurrencyParameterSensitivities.Meta |
meta()
The meta-bean for
CurrencyParameterSensitivities. |
CurrencyParameterSensitivities.Meta |
metaBean() |
CurrencyParameterSensitivities |
multipliedBy(double factor)
Returns an instance with the sensitivity values multiplied by the specified factor.
|
static CurrencyParameterSensitivities |
of(CurrencyParameterSensitivity... sensitivities)
Obtains an instance from an array of sensitivity entries.
|
static CurrencyParameterSensitivities |
of(CurrencyParameterSensitivity sensitivity)
Obtains an instance from a single sensitivity entry.
|
static CurrencyParameterSensitivities |
of(List<? extends CurrencyParameterSensitivity> sensitivities)
Obtains an instance from a list of sensitivity entries.
|
int |
size()
Gets the number of sensitivity entries.
|
CurrencyParameterSensitivities |
split()
Splits this sensitivity instance.
|
CurrencyParameterSensitivitiesBuilder |
toBuilder()
Returns a builder populated with the set of sensitivities from this instance.
|
String |
toString() |
MultiCurrencyAmount |
total()
Returns the total of the sensitivity values.
|
CurrencyAmount |
total(Currency resultCurrency,
FxRateProvider rateProvider)
Returns the total of the sensitivity values.
|
CurrencyParameterSensitivities |
withMarketDataNames(Function<MarketDataName<?>,MarketDataName<?>> nameFn)
Checks and adjusts the market data names.
|
CurrencyParameterSensitivities |
withParameterMetadatas(UnaryOperator<ParameterMetadata> mdFn)
Checks and adjusts the parameter metadata.
|
public static CurrencyParameterSensitivities empty()
public static CurrencyParameterSensitivitiesBuilder builder()
CurrencyParameterSensitivities.
The builder takes into account the parameter metadata when creating the sensitivity map. As such, the parameter metadata added to the builder must not be empty.
public static CurrencyParameterSensitivities of(CurrencyParameterSensitivity sensitivity)
sensitivity - the sensitivity entrypublic static CurrencyParameterSensitivities of(CurrencyParameterSensitivity... sensitivities)
The sensitivities are sorted using CurrencyParameterSensitivity.compareKey(com.opengamma.strata.market.param.CurrencyParameterSensitivity).
sensitivities - the sensitivitiespublic static CurrencyParameterSensitivities of(List<? extends CurrencyParameterSensitivity> sensitivities)
The sensitivities are sorted using CurrencyParameterSensitivity.compareKey(com.opengamma.strata.market.param.CurrencyParameterSensitivity).
sensitivities - the list of sensitivity entriespublic int size()
public CurrencyParameterSensitivity getSensitivity(MarketDataName<?> name, Currency currency)
name - the curve name to findcurrency - the currency to findIllegalArgumentException - if the name and currency do not match an entrypublic Optional<CurrencyParameterSensitivity> findSensitivity(MarketDataName<?> name, Currency currency)
If the sensitivity is not found, optional empty is returned.
name - the curve name to findcurrency - the currency to findpublic CurrencyParameterSensitivities combinedWith(CurrencyParameterSensitivity other)
This returns a new sensitivity instance with the specified sensitivity added. This instance is immutable and unaffected by this method.
The sensitivities are merged using market data name and currency as a key.
The parameter metadata is not checked, thus the caller must ensure the sensitivities
are compatible with the same metadata and parameter count.
To combine taking the metadata into account, use mergedWith(CurrencyParameterSensitivities).
other - the other parameter sensitivitypublic CurrencyParameterSensitivities combinedWith(CurrencyParameterSensitivities other)
This returns a new sensitivity instance with a combined list of parameter sensitivities. This instance is immutable and unaffected by this method.
The sensitivities are merged using market data name and currency as a key.
The parameter metadata is not checked, thus the caller must ensure the sensitivities
are compatible with the same metadata and parameter count.
To combine taking the metadata into account, use mergedWith(CurrencyParameterSensitivities).
other - the other parameter sensitivitiespublic CurrencyParameterSensitivities mergedWith(CurrencyParameterSensitivities other)
This returns a new sensitivity instance with a combined set of parameter sensitivities. This instance is immutable and unaffected by this method.
The sensitivities are merged using market data name and currency as a key. Each sensitivity is then merged taking into account the metadata, such as the tenor. As such, this method can only be used if the parameter metadata instances are not be empty.
other - the other parameter sensitivitiesIllegalArgumentException - if any metadata instance is emptypublic CurrencyParameterSensitivities withMarketDataNames(Function<MarketDataName<?>,MarketDataName<?>> nameFn)
The supplied function is invoked for each market data name in this sensitivities. If the function returns the same name for two different inputs, the sensitivity values will be summed. A typical use case would be to convert index names to curve names valid for an underlying system.
nameFn - the function for checking and adjusting the nameRuntimeException - if the function throws an exceptionpublic CurrencyParameterSensitivities withParameterMetadatas(UnaryOperator<ParameterMetadata> mdFn)
The supplied function is invoked for each parameter metadata in this sensitivities. If the function returns the same metadata for two different inputs, the sensitivity values will be summed. A typical use case would be to normalize parameter metadata tenors to be valid for an underlying system.
mdFn - the function for checking and adjusting the metadataIllegalArgumentException - if any metadata instance is emptyRuntimeException - if the function throws an exceptionpublic CurrencyParameterSensitivities convertedTo(Currency resultCurrency, FxRateProvider rateProvider)
Any FX conversion that is required will use rates from the provider.
convertedTo in interface FxConvertible<CurrencyParameterSensitivities>resultCurrency - the currency of the resultrateProvider - the provider of FX ratesRuntimeException - if no FX rate could be foundpublic CurrencyParameterSensitivities split()
This examines each individual sensitivity to see if it can be split.
If any can be split, the result will contain the combination of the split sensitivities.
public CurrencyAmount total(Currency resultCurrency, FxRateProvider rateProvider)
The result is the total of all values, as converted to the specified currency. Any FX conversion that is required will use rates from the provider.
resultCurrency - the currency of the resultrateProvider - the provider of FX ratesRuntimeException - if no FX rate could be foundpublic MultiCurrencyAmount total()
The result is the total of all values, in whatever currency they are defined.
public CurrencyParameterSensitivities multipliedBy(double factor)
The result will consist of the same entries, but with each sensitivity value multiplied. This instance is immutable and unaffected by this method.
factor - the multiplicative factorpublic CurrencyParameterSensitivities mapSensitivities(DoubleUnaryOperator operator)
The result will consist of the same entries, but with the operator applied to each sensitivity value. This instance is immutable and unaffected by this method.
This is used to apply a mathematical operation to the sensitivity values. For example, the operator could multiply the sensitivities by a constant, or take the inverse.
inverse = base.mapSensitivities(value -> 1 / value);
operator - the operator to be applied to the sensitivitiespublic CurrencyParameterSensitivities mapSensitivitiesWithIndex(IntDoubleToDoubleFunction function)
Each value in the sensitivity array will be operated on. The function receives both the index and the value. For example, the operator could multiply the sensitivities by the index.
result = base.mapSensitivityWithIndex((index, value) -> index * value);This instance is immutable and unaffected by this method.
function - the function to be applied to the sensitivitiespublic boolean equalWithTolerance(CurrencyParameterSensitivities other, double tolerance)
This returns true if the two instances have the same keys, with arrays of the
same length, where the double values are equal within the specified tolerance.
other - the other sensitivitytolerance - the tolerancepublic CurrencyParameterSensitivitiesBuilder toBuilder()
The builder takes into account the parameter metadata when creating the sensitivity map. As such, the parameter metadata added to the builder must not be empty.
IllegalArgumentException - if any metadata instance is emptypublic static CurrencyParameterSensitivities.Meta meta()
CurrencyParameterSensitivities.public CurrencyParameterSensitivities.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic ImmutableList<CurrencyParameterSensitivity> getSensitivities()
Each entry includes details of the ParameterizedData it relates to.
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.