Class CrossGammaParameterSensitivity

  • All Implemented Interfaces:
    FxConvertible<CrossGammaParameterSensitivity>, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class CrossGammaParameterSensitivity
    extends Object
    implements FxConvertible<CrossGammaParameterSensitivity>, org.joda.beans.ImmutableBean, Serializable
    The second order parameter sensitivity for parameterized market data.

    Parameter sensitivity is the sensitivity of a value to the parameters of a parameterized market data object that is used to determine the value. The main application of this class is the parameter sensitivities for curves. Thus ParameterizedData is typically Curve.

    The sensitivity is expressed as a matrix. The (i,j) component is the sensitivity of the i-th component of the parameterMetadata delta to the j-th parameter in order.

    The sensitivity represents a monetary value in the specified currency.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static CrossGammaParameterSensitivity of​(MarketDataName<?> marketDataName,
                                                        List<? extends ParameterMetadata> parameterMetadata,
                                                        Currency currency,
                                                        DoubleMatrix sensitivity)
        Obtains an instance from the market data name, metadata, currency and sensitivity.

        This creates a sensitivity instance which stores the second order sensitivity values to a single market data, i.e., the block diagonal part of the full second order sensitivity matrix.

        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.

        Parameters:
        marketDataName - the name of the market data that the sensitivity refers to
        parameterMetadata - the parameter metadata
        currency - the currency of the sensitivity
        sensitivity - the sensitivity values, one for each parameter
        Returns:
        the sensitivity object
      • of

        public static CrossGammaParameterSensitivity of​(MarketDataName<?> marketDataName,
                                                        List<? extends ParameterMetadata> parameterMetadata,
                                                        MarketDataName<?> marketDataNameOther,
                                                        List<? extends ParameterMetadata> parameterMetadataOther,
                                                        Currency currency,
                                                        DoubleMatrix sensitivity)
        Obtains an instance from the market data names, metadatas, currency and sensitivity.

        This creates a sensitivity instance which stores the second order sensitivity values: the delta of a market data to another market data. The first market data and the second market data can be the same.

        The market data name identifies the ParameterizedData instance that was queried. The parameter metadata provides information on each parameter.

        Parameters:
        marketDataName - the name of the first market data that the sensitivity refers to
        parameterMetadata - the first parameter metadata
        marketDataNameOther - the name of the second market data that the sensitivity refers to
        parameterMetadataOther - the second parameter metadata
        currency - the currency of the sensitivity
        sensitivity - the sensitivity values, one for each parameter
        Returns:
        the sensitivity object
      • of

        public static CrossGammaParameterSensitivity of​(MarketDataName<?> marketDataName,
                                                        List<? extends ParameterMetadata> parameterMetadata,
                                                        List<Pair<MarketDataName<?>,​List<? extends ParameterMetadata>>> order,
                                                        Currency currency,
                                                        DoubleMatrix sensitivity)
        Obtains an instance from the market data names, metadatas, currency and sensitivity.

        This creates a sensitivity instance which stores the second order sensitivity values: the delta of a market data to a set of other market data. The market data set is represented in terms of List<Pair<MarketDataName<?>, List<? extends ParameterMetadata>>>. which defines the order of the sensitivity values.

        The market data name identifies the ParameterizedData instance that was queried. The parameter metadata provides information on each parameter.

        Parameters:
        marketDataName - the name of the market data that the sensitivity refers to
        parameterMetadata - the parameter metadata
        order - the order
        currency - the currency of the sensitivity
        sensitivity - the sensitivity values, one for each parameter
        Returns:
        the sensitivity object
      • getParameterCount

        public int getParameterCount()
        Gets the number of parameters.

        This returns the number of parameters in the ParameterizedData instance which is the same size as the sensitivity array.

        Returns:
        the number of parameters
      • getParameterMetadata

        public ParameterMetadata getParameterMetadata​(int parameterIndex)
        Gets the parameter metadata at the specified index.

        If there is no specific parameter metadata, an empty instance will be returned.

        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        Returns:
        the metadata of the parameter
        Throws:
        IndexOutOfBoundsException - if the index is invalid
      • compareKey

        public int compareKey​(CrossGammaParameterSensitivity other)
        Compares the key of two sensitivity objects, excluding the parameter sensitivity values.
        Parameters:
        other - the other sensitivity object
        Returns:
        positive if greater, zero if equal, negative if less
      • multipliedBy

        public CrossGammaParameterSensitivity multipliedBy​(double factor)
        Returns an instance with the sensitivity values multiplied by the specified factor.

        Each value in the sensitivity array will be multiplied by the factor.

        Parameters:
        factor - the multiplicative factor
        Returns:
        an instance based on this one, with each sensitivity multiplied by the factor
      • mapSensitivity

        public CrossGammaParameterSensitivity mapSensitivity​(DoubleUnaryOperator operator)
        Returns an instance with the specified operation applied to the sensitivity values.

        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);
         
        Parameters:
        operator - the operator to be applied to the sensitivities
        Returns:
        an instance based on this one, with the operator applied to the sensitivity values
      • withSensitivity

        public CrossGammaParameterSensitivity withSensitivity​(DoubleMatrix sensitivity)
        Returns an instance with new parameter sensitivity values.
        Parameters:
        sensitivity - the new sensitivity values
        Returns:
        an instance based on this one, with the specified sensitivity values
      • total

        public CurrencyAmount total()
        Returns the total of the sensitivity values.
        Returns:
        the total sensitivity values
      • diagonal

        public CurrencyParameterSensitivity diagonal()
        Returns the diagonal part of the sensitivity as CurrencyParameterSensitivity.
        Returns:
        the diagonal part
      • getSensitivity

        public CrossGammaParameterSensitivity getSensitivity​(MarketDataName<?> name)
        Returns the sensitivity to the market data specified by name.

        This returns a sensitivity instance which stores the sensitivity of the marketDataName delta to another market data of name.

        Parameters:
        name - the name
        Returns:
        the sensitivity
        Throws:
        IllegalArgumentException - if the name does not match an entry
      • getMarketDataName

        public MarketDataName<?> getMarketDataName()
        Gets the market data name.

        This name is used in the market data system to identify the data that the sensitivities refer to.

        Returns:
        the value of the property, not null
      • getParameterMetadata

        public ImmutableList<ParameterMetadata> getParameterMetadata()
        Gets the list of parameter metadata.

        There is one entry for each parameter.

        Returns:
        the value of the property, not null
      • getOrder

        public ImmutableList<Pair<MarketDataName<?>,​List<? extends ParameterMetadata>>> getOrder()
        Gets the sensitivity order.

        This defines the order of sensitivity values, which can be used as a key to interpret sensitivity.

        Returns:
        the value of the property, not null
      • getCurrency

        public Currency getCurrency()
        Gets the currency of the sensitivity.
        Returns:
        the value of the property, not null
      • getSensitivity

        public DoubleMatrix getSensitivity()
        Gets the parameter sensitivity values.

        The curve delta sensitivities to parameterized market data. This is a n x m matrix, where n must agree with the size of parameterMetadata and m must be the sum of parameter count in order.

        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object