Class PointSensitivities

  • All Implemented Interfaces:
    FxConvertible<PointSensitivities>, java.io.Serializable, Bean, ImmutableBean

    public final class PointSensitivities
    extends java.lang.Object
    implements FxConvertible<PointSensitivities>, ImmutableBean, java.io.Serializable
    A collection of point sensitivities.

    Contains a list of point sensitivity objects, each referring to a specific point on a curve that was queried. The order of the list has no specific meaning, but does allow duplicates.

    For example, the point 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 date that the curve was queried and the resulting multiplier.

    When creating an instance, consider using MutablePointSensitivities.

    One way of viewing this class is as a Map from a specific sensitivity key to a double sensitivity value. However, instead or being structured as a Map, the data is structured as a List, with the key and value in each entry.

    See Also:
    Serialized Form
    • Method Detail

      • empty

        public static PointSensitivities empty()
        An empty sensitivity instance.
        Returns:
        the empty instance
      • of

        public static PointSensitivities of​(PointSensitivity... sensitivity)
        Obtains an instance from an array of sensitivity entries.
        Parameters:
        sensitivity - the sensitivity entry
        Returns:
        the sensitivities instance
      • of

        public static PointSensitivities of​(java.util.List<? extends PointSensitivity> sensitivities)
        Obtains an instance from a list of sensitivity entries.
        Parameters:
        sensitivities - the list of sensitivity entries
        Returns:
        the sensitivities instance
      • size

        public int size()
        Gets the number of sensitivity entries.
        Returns:
        the size of the internal list of point sensitivities
      • combinedWith

        public PointSensitivities combinedWith​(PointSensitivities other)
        Combines this point sensitivities with another instance.

        This returns a new sensitivity instance with a combined list of point sensitivities. This instance is immutable and unaffected by this method. The result may contain duplicate point sensitivities.

        Parameters:
        other - the other point sensitivities
        Returns:
        a PointSensitivities based on this one, with the other instance added
      • multipliedBy

        public PointSensitivities multipliedBy​(double factor)
        Multiplies the sensitivities in this instance by the specified factor.

        The result will consist of the same entries, but with each sensitivity value multiplied. This instance is immutable and unaffected by this method.

        Parameters:
        factor - the multiplicative factor
        Returns:
        a PointSensitivities based on this one, with each sensitivity multiplied by the factor
      • mapSensitivities

        public PointSensitivities mapSensitivities​(java.util.function.DoubleUnaryOperator operator)
        Applies an operation to the sensitivities in this instance.

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

        public PointSensitivities normalized()
        Normalizes the point sensitivities by sorting and merging.

        The list of sensitivities is sorted and then merged. Any two entries that represent the same curve query are merged. For example, if there are two point sensitivities that were created based on the same curve, currency and fixing date, then the entries are combined, summing the sensitivity value.

        The intention is that normalization occurs after gathering all the point sensitivities.

        This instance is immutable and unaffected by this method.

        Returns:
        a PointSensitivities based on this one, with the sensitivities normalized
      • toMutable

        public MutablePointSensitivities toMutable()
        Returns a mutable version of this object.

        The result is an instance of the mutable MutablePointSensitivities. It will contain the same individual sensitivity entries.

        Returns:
        the mutable sensitivity instance, not null
      • equalWithTolerance

        public boolean equalWithTolerance​(PointSensitivities other,
                                          double tolerance)
        Checks if this sensitivity equals another within the specified tolerance.

        This returns true if the two instances have the list of PointSensitivity, where the sensitivity double values are compared within the specified tolerance. It is expected that this comparator will be used on the normalized version of the sensitivity.

        Parameters:
        other - the other sensitivity
        tolerance - the tolerance
        Returns:
        true if equal up to the tolerance
      • convertedTo

        public PointSensitivities convertedTo​(Currency resultCurrency,
                                              FxRateProvider rateProvider)
        Description copied from interface: FxConvertible
        Converts this instance to an equivalent amount in the specified currency.

        The result, which may be of a different type, will be expressed in terms of the given currency. Any FX conversion that is required will use rates from the provider.

        Specified by:
        convertedTo in interface FxConvertible<PointSensitivities>
        Parameters:
        resultCurrency - the currency of the result
        rateProvider - the provider of FX rates
        Returns:
        the converted instance, which should be expressed in the specified currency
      • meta

        public static PointSensitivities.Meta meta()
        The meta-bean for PointSensitivities.
        Returns:
        the meta-bean, not null
      • getSensitivities

        public com.google.common.collect.ImmutableList<PointSensitivity> getSensitivities()
        Gets the point sensitivities.

        Each entry includes details of the market data query it relates to.

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

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object