public final class CurrencyParameterSensitivity extends Object implements FxConvertible<CurrencyParameterSensitivity>, org.joda.beans.ImmutableBean, Serializable
Parameter sensitivity is the sensitivity of a value to the parameters of a
parameterized market data object that is used to determine the value.
Common ParameterizedData implementations include Curve and Surface.
The sensitivity is expressed as an array, with one entry for each parameter in the ParameterizedData.
The sensitivity represents a monetary value in the specified currency.
A single CurrencyParameterSensitivity represents the sensitivity to a single ParameterizedData instance.
However, a ParameterizedData instance can itself be backed by more than one underlying instance.
For example, a curve formed from two underlying curves.
Information about the split between these underlying instances can optionally be stored.
| Modifier and Type | Class and Description |
|---|---|
static class |
CurrencyParameterSensitivity.Builder
The bean-builder for
CurrencyParameterSensitivity. |
static class |
CurrencyParameterSensitivity.Meta
The meta-bean for
CurrencyParameterSensitivity. |
| Modifier and Type | Method and Description |
|---|---|
static CurrencyParameterSensitivity.Builder |
builder()
Returns a builder used to create an instance of the bean.
|
static CurrencyParameterSensitivity |
combine(MarketDataName<?> marketDataName,
CurrencyParameterSensitivity... sensitivities)
Combines two or more instances to form a single sensitivity instance.
|
int |
compareKey(CurrencyParameterSensitivity other)
Compares the key of two sensitivity objects, excluding the parameter sensitivity values.
|
CurrencyParameterSensitivity |
convertedTo(Currency resultCurrency,
FxRateProvider rateProvider)
Converts this sensitivity to an equivalent in the specified currency.
|
boolean |
equals(Object obj) |
Currency |
getCurrency()
Gets the currency of the sensitivity.
|
MarketDataName<?> |
getMarketDataName()
Gets the market data name.
|
int |
getParameterCount()
Gets the number of parameters.
|
ImmutableList<ParameterMetadata> |
getParameterMetadata()
Gets the list of parameter metadata.
|
ParameterMetadata |
getParameterMetadata(int parameterIndex)
Gets the parameter metadata at the specified index.
|
Optional<List<ParameterSize>> |
getParameterSplit()
Gets the split of parameters between the underlying parameterized data.
|
DoubleArray |
getSensitivity()
Gets the parameter sensitivity values.
|
int |
hashCode() |
CurrencyParameterSensitivity |
mapSensitivity(DoubleUnaryOperator operator)
Returns an instance with the specified operation applied to the sensitivity values.
|
CurrencyParameterSensitivity |
mapSensitivityWithIndex(IntDoubleToDoubleFunction function)
Returns an instance with an operation applied to each indexed value in the sensitivity values.
|
static CurrencyParameterSensitivity.Meta |
meta()
The meta-bean for
CurrencyParameterSensitivity. |
CurrencyParameterSensitivity.Meta |
metaBean() |
CurrencyParameterSensitivity |
multipliedBy(double factor)
Returns an instance with the sensitivity values multiplied by the specified factor.
|
static CurrencyParameterSensitivity |
of(MarketDataName<?> marketDataName,
Currency currency,
DoubleArray sensitivity)
Obtains an instance from the market data name, currency and sensitivity.
|
static CurrencyParameterSensitivity |
of(MarketDataName<?> marketDataName,
Currency currency,
Map<? extends ParameterMetadata,Double> sensitivityMetadataMap)
Obtains an instance from the market data name, currency and a map of metadata to sensitivity.
|
static CurrencyParameterSensitivity |
of(MarketDataName<?> marketDataName,
List<? extends ParameterMetadata> parameterMetadata,
Currency currency,
DoubleArray sensitivity)
Obtains an instance from the market data name, metadata, currency and sensitivity.
|
static CurrencyParameterSensitivity |
of(MarketDataName<?> marketDataName,
List<? extends ParameterMetadata> parameterMetadata,
Currency currency,
DoubleArray sensitivity,
List<ParameterSize> parameterSplit)
Obtains an instance from the market data name, metadata, currency, sensitivity and parameter split.
|
CurrencyParameterSensitivity |
plus(CurrencyParameterSensitivity otherSensitivty)
Returns an instance with the specified sensitivity array added to the array in this instance.
|
CurrencyParameterSensitivity |
plus(DoubleArray otherSensitivty)
Returns an instance with the specified sensitivity array added to the array in this instance.
|
MapStream<ParameterMetadata,Double> |
sensitivities()
Converts this instance to a stream of sensitivity, keyed by the parameter metadata.
|
ImmutableList<CurrencyParameterSensitivity> |
split()
Splits this sensitivity instance.
|
CurrencyParameterSensitivity.Builder |
toBuilder()
Returns a builder that allows this bean to be mutated.
|
<T> ImmutableMap<T,Double> |
toSensitivityMap(Class<T> identifierType)
Converts this instance to a map of sensitivities, keyed by the identifier.
|
String |
toString() |
CurrencyAmount |
total()
Returns the total of the sensitivity values.
|
UnitParameterSensitivity |
toUnitParameterSensitivity()
Converts this instance to the equivalent unit sensitivity.
|
CurrencyParameterSensitivity |
withSensitivity(DoubleArray sensitivity)
Returns an instance with new parameter sensitivity values.
|
public static CurrencyParameterSensitivity of(MarketDataName<?> marketDataName, List<? extends ParameterMetadata> parameterMetadata, Currency currency, DoubleArray sensitivity)
The market data name identifies the ParameterizedData instance that was queried.
The parameter metadata provides information on each parameter.
The size of the parameter metadata list must match the size of the sensitivity array.
marketDataName - the name of the market data that the sensitivity refers toparameterMetadata - the parameter metadatacurrency - the currency of the sensitivitysensitivity - the sensitivity values, one for each parameterpublic static CurrencyParameterSensitivity of(MarketDataName<?> marketDataName, Currency currency, DoubleArray sensitivity)
The market data name identifies the ParameterizedData instance that was queried.
The parameter metadata will be empty.
The size of the parameter metadata list must match the size of the sensitivity array.
marketDataName - the name of the market data that the sensitivity refers tocurrency - the currency of the sensitivitysensitivity - the sensitivity values, one for each parameterpublic static CurrencyParameterSensitivity of(MarketDataName<?> marketDataName, List<? extends ParameterMetadata> parameterMetadata, Currency currency, DoubleArray sensitivity, List<ParameterSize> parameterSplit)
The market data name identifies the ParameterizedData instance that was queried.
The parameter metadata provides information on each parameter.
The size of the parameter metadata list must match the size of the sensitivity array.
The parameter split allows the sensitivity to represent the split between two or more
underlying ParameterizedData instances. The sum of the parameters in the split
must equal the size of the sensitivity array, and each name must be unique.
marketDataName - the name of the market data that the sensitivity refers toparameterMetadata - the parameter metadatacurrency - the currency of the sensitivitysensitivity - the sensitivity values, one for each parameterparameterSplit - the split between the underlying ParameterizedData instancespublic static CurrencyParameterSensitivity of(MarketDataName<?> marketDataName, Currency currency, Map<? extends ParameterMetadata,Double> sensitivityMetadataMap)
The market data name identifies the ParameterizedData instance that was queried.
The parameter metadata provides information on each parameter.
One use of this method is to provide tenor-based sensitivity via TenorParameterMetadata.
marketDataName - the name of the market data that the sensitivity refers tocurrency - the currency of the sensitivitysensitivityMetadataMap - the map of parameter metadata to sensitivitypublic static CurrencyParameterSensitivity combine(MarketDataName<?> marketDataName, CurrencyParameterSensitivity... sensitivities)
The result will store information about the separate instances allowing it to be split() later.
If a single sensitivity is supplied and refers to the same market data then it will be returned unmodified. Otherwise a new instance will be returned with a single parameter split (the original sensitivity).
marketDataName - the combined name of the market data that the sensitivity refers tosensitivities - the sensitivity instances to combine, two or morepublic int getParameterCount()
This returns the number of parameters in the ParameterizedData instance
which is the same size as the sensitivity array.
public ParameterMetadata getParameterMetadata(int parameterIndex)
If there is no specific parameter metadata, an empty instance will be returned.
parameterIndex - the zero-based index of the parameter to getIndexOutOfBoundsException - if the index is invalidpublic int compareKey(CurrencyParameterSensitivity other)
other - the other sensitivity objectpublic CurrencyParameterSensitivity convertedTo(Currency resultCurrency, FxRateProvider rateProvider)
Any FX conversion that is required will use rates from the provider.
convertedTo in interface FxConvertible<CurrencyParameterSensitivity>resultCurrency - the currency of the resultrateProvider - the provider of FX ratesRuntimeException - if no FX rate could be foundpublic CurrencyParameterSensitivity multipliedBy(double factor)
Each value in the sensitivity array will be multiplied by the factor.
factor - the multiplicative factorpublic CurrencyParameterSensitivity mapSensitivity(DoubleUnaryOperator operator)
Each value in the sensitivity array will be operated on. For example, the operator could multiply the sensitivities by a constant, or take the inverse.
inverse = base.mapSensitivity(value -> 1 / value);
operator - the operator to be applied to the sensitivitiespublic CurrencyParameterSensitivity mapSensitivityWithIndex(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 CurrencyParameterSensitivity withSensitivity(DoubleArray sensitivity)
sensitivity - the new sensitivity valuespublic CurrencyParameterSensitivity plus(DoubleArray otherSensitivty)
The specified array must match the size of the array in this instance.
otherSensitivty - the other parameter sensitivityIllegalArgumentException - if the market data name, metadata or parameter split differspublic CurrencyParameterSensitivity plus(CurrencyParameterSensitivity otherSensitivty)
The specified instance must have the same name, metadata, currency and parameter split as this instance.
otherSensitivty - the other parameter sensitivityIllegalArgumentException - if the market data name, metadata or parameter split differspublic ImmutableList<CurrencyParameterSensitivity> split()
A single sensitivity instance may be based on more than one underlying ParameterizedData,
as represented by getParameterSplit(). Calling this method returns a list
where the sensitivity of this instance has been split into multiple instances as per
the parameter split definition. In the common case where there is a single underlying
ParameterizedData, the list will be of size one containing this instance.
public CurrencyAmount total()
public MapStream<ParameterMetadata,Double> sensitivities()
This returns a MapStream keyed by the parameter metadata.
public <T> ImmutableMap<T,Double> toSensitivityMap(Class<T> identifierType)
This returns a Map keyed by the identifier of the metadata.
For example, this could be used to extract a Map<Tenor, Double>.
T - the type of the identifieridentifierType - the type of the parameter metadata identifierClassCastException - if the identifier of the parameter metadata does not match the specified typepublic UnitParameterSensitivity toUnitParameterSensitivity()
The result has the same sensitivity values, but no longer records the currency.
public static CurrencyParameterSensitivity.Meta meta()
CurrencyParameterSensitivity.public static CurrencyParameterSensitivity.Builder builder()
public CurrencyParameterSensitivity.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic MarketDataName<?> getMarketDataName()
This name is used in the market data system to identify the data that the sensitivities refer to.
public ImmutableList<ParameterMetadata> getParameterMetadata()
There is one entry for each parameter.
public Currency getCurrency()
public DoubleArray getSensitivity()
There is one sensitivity value for each parameter.
public Optional<List<ParameterSize>> getParameterSplit()
A single CurrencyParameterSensitivity represents the sensitivity to a single ParameterizedData instance.
However, a ParameterizedData instance can itself be backed by more than one underlying instance.
For example, a curve formed from two underlying curves.
If this list is present, it represents how to split this sensitivity between the underlying instances.
public CurrencyParameterSensitivity.Builder toBuilder()
Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.