Class CurveSensitivities
- java.lang.Object
-
- com.opengamma.strata.market.sensitivity.CurveSensitivities
-
- All Implemented Interfaces:
CalculationTarget
,FxConvertible<CurveSensitivities>
,Sensitivities
,PortfolioItem
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class CurveSensitivities extends Object implements Sensitivities, FxConvertible<CurveSensitivities>, org.joda.beans.ImmutableBean, Serializable
Sensitivity to a set of curves, used to pass risk into calculations.Sometimes it is useful to pass in a representation of risk rather than explicitly listing the current portfolio of trades and/or positions. This target is designed to allow this.
A map of sensitivities is provided, allowing both delta and gamma to be included if desired.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CurveSensitivities.Meta
The meta-bean forCurveSensitivities
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CurveSensitivitiesBuilder
builder(PortfolioItemInfo info)
Returns a builder that can be used to create an instance ofCurveSensitivities
.CurveSensitivities
convertedTo(Currency resultCurrency, FxRateProvider rateProvider)
Converts the sensitivities in this instance to an equivalent in the specified currency.static CurveSensitivities
empty()
Obtains an empty instance.boolean
equals(Object obj)
Optional<CurrencyParameterSensitivities>
findTypedSensitivity(CurveSensitivitiesType type)
Finds a sensitivity instance by type, returning empty if not found.PortfolioItemInfo
getInfo()
Gets the additional information.ImmutableMap<CurveSensitivitiesType,CurrencyParameterSensitivities>
getTypedSensitivities()
Gets the sensitivities, keyed by type.CurrencyParameterSensitivities
getTypedSensitivity(CurveSensitivitiesType type)
Gets a sensitivity instance by type, throwing an exception if not found.int
hashCode()
CurveSensitivities
mergedWith(CurveSensitivities other)
Combines this set of sensitivities with another set.CurveSensitivities
mergedWith(Map<CurveSensitivitiesType,CurrencyParameterSensitivities> other)
Merges this set of sensitivities with another set.static CurveSensitivities.Meta
meta()
The meta-bean forCurveSensitivities
.CurveSensitivities.Meta
metaBean()
static CurveSensitivities
of(PortfolioItemInfo info, CurveSensitivitiesType type, CurrencyParameterSensitivities sensitivities)
Obtains an instance from a single set of sensitivities.static CurveSensitivities
of(PortfolioItemInfo info, Map<CurveSensitivitiesType,CurrencyParameterSensitivities> typedSensitivities)
Obtains an instance from a map of sensitivities.PortfolioItemSummary
summarize()
Summarizes the portfolio item.static Collector<CurveSensitivities,?,CurveSensitivities>
toMergedSensitivities()
Returns a collector that merges sensitivities.String
toString()
CurveSensitivities
withInfo(PortfolioItemInfo info)
Returns an instance with the specified info.CurveSensitivities
withMarketDataNames(Function<MarketDataName<?>,MarketDataName<?>> nameFn)
Checks and adjusts the market data names.CurveSensitivities
withParameterMetadatas(UnaryOperator<ParameterMetadata> mdFn)
Checks and adjusts the parameter metadata.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.product.PortfolioItem
getId
-
-
-
-
Method Detail
-
empty
public static CurveSensitivities empty()
Obtains an empty instance.- Returns:
- the empty sensitivities instance
-
builder
public static CurveSensitivitiesBuilder builder(PortfolioItemInfo info)
Returns a builder that can be used to create an instance ofCurveSensitivities
.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.
- Parameters:
info
- the additional information- Returns:
- the builder
-
of
public static CurveSensitivities of(PortfolioItemInfo info, CurveSensitivitiesType type, CurrencyParameterSensitivities sensitivities)
Obtains an instance from a single set of sensitivities.- Parameters:
info
- the additional informationtype
- the type of the sensitivitiessensitivities
- the sensitivities- Returns:
- the sensitivities instance
-
of
public static CurveSensitivities of(PortfolioItemInfo info, Map<CurveSensitivitiesType,CurrencyParameterSensitivities> typedSensitivities)
Obtains an instance from a map of sensitivities.- Parameters:
info
- the additional informationtypedSensitivities
- the map of sensitivities by type- Returns:
- the sensitivities instance
-
toMergedSensitivities
public static Collector<CurveSensitivities,?,CurveSensitivities> toMergedSensitivities()
Returns a collector that merges sensitivities.- Returns:
- a collector that can merge sensitivities
-
getTypedSensitivity
public CurrencyParameterSensitivities getTypedSensitivity(CurveSensitivitiesType type)
Gets a sensitivity instance by type, throwing an exception if not found.- Parameters:
type
- the type to get- Returns:
- the sensitivity
- Throws:
IllegalArgumentException
- if the type is not found
-
findTypedSensitivity
public Optional<CurrencyParameterSensitivities> findTypedSensitivity(CurveSensitivitiesType type)
Finds a sensitivity instance by type, returning empty if not found.- Parameters:
type
- the type to find- Returns:
- the sensitivity, empty if not found
-
mergedWith
public CurveSensitivities mergedWith(Map<CurveSensitivitiesType,CurrencyParameterSensitivities> other)
Merges this set of sensitivities with another set.This returns a new curve sensitivities with a combined map of typed sensitivities. Any sensitivities of the same type will be combined as though using
CurrencyParameterSensitivities.mergedWith(CurrencyParameterSensitivities)
.- Parameters:
other
- the other parameter sensitivities- Returns:
- an instance based on this one, with the other instance added
-
mergedWith
public CurveSensitivities mergedWith(CurveSensitivities other)
Combines this set of sensitivities with another set.This returns a new curve sensitivities with a combined map of typed sensitivities. Any sensitivities of the same type will be combined as though using
CurrencyParameterSensitivities.mergedWith(CurrencyParameterSensitivities)
. The identifier and attributes of this instance will take precedence.- Parameters:
other
- the other parameter sensitivities- Returns:
- an instance based on this one, with the other instance added
-
withMarketDataNames
public CurveSensitivities withMarketDataNames(Function<MarketDataName<?>,MarketDataName<?>> nameFn)
Checks and adjusts the market data names.The supplied function is invoked for each market data name in this sensitivities. A typical use case would be to convert index names to curve names valid for an underlying system.
- Parameters:
nameFn
- the function for checking and adjusting the name- Returns:
- the adjusted sensitivity
- Throws:
RuntimeException
- if the function throws an exception
-
withParameterMetadatas
public CurveSensitivities withParameterMetadatas(UnaryOperator<ParameterMetadata> mdFn)
Checks and adjusts the parameter metadata.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 value will be summed. A typical use case would be to normalize parameter metadata tenors to be valid for an underlying system.
- Parameters:
mdFn
- the function for checking and adjusting the metadata- Returns:
- the adjusted sensitivity
- Throws:
RuntimeException
- if the function throws an exception
-
convertedTo
public CurveSensitivities convertedTo(Currency resultCurrency, FxRateProvider rateProvider)
Converts the sensitivities in this instance to an equivalent in the specified currency.Any FX conversion that is required will use rates from the provider.
- Specified by:
convertedTo
in interfaceFxConvertible<CurveSensitivities>
- Parameters:
resultCurrency
- the currency of the resultrateProvider
- the provider of FX rates- Returns:
- the sensitivity object expressed in terms of the result currency
- Throws:
RuntimeException
- if no FX rate could be found
-
summarize
public PortfolioItemSummary summarize()
Description copied from interface:PortfolioItem
Summarizes the portfolio item.This provides a summary, including a human readable description.
- Specified by:
summarize
in interfacePortfolioItem
- Returns:
- the summary of the item
-
withInfo
public CurveSensitivities withInfo(PortfolioItemInfo info)
Description copied from interface:Sensitivities
Returns an instance with the specified info.- Specified by:
withInfo
in interfacePortfolioItem
- Specified by:
withInfo
in interfaceSensitivities
- Parameters:
info
- the new info- Returns:
- the instance with the specified info
-
meta
public static CurveSensitivities.Meta meta()
The meta-bean forCurveSensitivities
.- Returns:
- the meta-bean, not null
-
metaBean
public CurveSensitivities.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getInfo
public PortfolioItemInfo getInfo()
Gets the additional information.This allows additional information to be attached to the sensitivities.
- Specified by:
getInfo
in interfacePortfolioItem
- Specified by:
getInfo
in interfaceSensitivities
- Returns:
- the value of the property, not null
-
getTypedSensitivities
public ImmutableMap<CurveSensitivitiesType,CurrencyParameterSensitivities> getTypedSensitivities()
Gets the sensitivities, keyed by type.The map allows sensitivity to different types to be expressed. For example, there might be both delta and gamma sensitivity.
- Returns:
- the value of the property, not null
-
-