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 classCurveSensitivities.MetaThe meta-bean forCurveSensitivities.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CurveSensitivitiesBuilderbuilder(PortfolioItemInfo info)Returns a builder that can be used to create an instance ofCurveSensitivities.CurveSensitivitiesconvertedTo(Currency resultCurrency, FxRateProvider rateProvider)Converts the sensitivities in this instance to an equivalent in the specified currency.static CurveSensitivitiesempty()Obtains an empty instance.booleanequals(Object obj)Optional<CurrencyParameterSensitivities>findTypedSensitivity(CurveSensitivitiesType type)Finds a sensitivity instance by type, returning empty if not found.PortfolioItemInfogetInfo()Gets the additional information.ImmutableMap<CurveSensitivitiesType,CurrencyParameterSensitivities>getTypedSensitivities()Gets the sensitivities, keyed by type.CurrencyParameterSensitivitiesgetTypedSensitivity(CurveSensitivitiesType type)Gets a sensitivity instance by type, throwing an exception if not found.inthashCode()CurveSensitivitiesmergedWith(CurveSensitivities other)Combines this set of sensitivities with another set.CurveSensitivitiesmergedWith(Map<CurveSensitivitiesType,CurrencyParameterSensitivities> other)Merges this set of sensitivities with another set.static CurveSensitivities.Metameta()The meta-bean forCurveSensitivities.CurveSensitivities.MetametaBean()static CurveSensitivitiesof(PortfolioItemInfo info, CurveSensitivitiesType type, CurrencyParameterSensitivities sensitivities)Obtains an instance from a single set of sensitivities.static CurveSensitivitiesof(PortfolioItemInfo info, Map<CurveSensitivitiesType,CurrencyParameterSensitivities> typedSensitivities)Obtains an instance from a map of sensitivities.PortfolioItemSummarysummarize()Summarizes the portfolio item.static Collector<CurveSensitivities,?,CurveSensitivities>toMergedSensitivities()Returns a collector that merges sensitivities.StringtoString()CurveSensitivitieswithInfo(PortfolioItemInfo info)Returns an instance with the specified info.CurveSensitivitieswithMarketDataNames(Function<MarketDataName<?>,MarketDataName<?>> nameFn)Checks and adjusts the market data names.CurveSensitivitieswithParameterMetadatas(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:
convertedToin 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:PortfolioItemSummarizes the portfolio item.This provides a summary, including a human readable description.
- Specified by:
summarizein interfacePortfolioItem- Returns:
- the summary of the item
-
withInfo
public CurveSensitivities withInfo(PortfolioItemInfo info)
Description copied from interface:SensitivitiesReturns an instance with the specified info.- Specified by:
withInfoin interfacePortfolioItem- Specified by:
withInfoin 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:
metaBeanin interfaceorg.joda.beans.Bean
-
getInfo
public PortfolioItemInfo getInfo()
Gets the additional information.This allows additional information to be attached to the sensitivities.
- Specified by:
getInfoin interfacePortfolioItem- Specified by:
getInfoin 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
-
-