Class AddFixedCurve

  • All Implemented Interfaces:
    Curve, ParameterizedData, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

    public final class AddFixedCurve
    extends Object
    implements Curve, org.joda.beans.ImmutableBean, Serializable
    A curve formed from two curves, the fixed curve and the spread curve.

    The spread curve is the primary curve, providing the metadata, parameters, sensitivity and perturbation. The fixed curve only affects the shape of the curve via the yValue(double) and firstDerivative(double) methods. The fixed curve is not exposed in the parameters.

    See Also:
    Serialized Form
    • Method Detail

      • of

        public static AddFixedCurve of​(Curve fixedCurve,
                                       Curve spreadCurve)
        Creates a curve as the sum of a fixed curve and a spread curve.
        Parameters:
        fixedCurve - the fixed curve
        spreadCurve - the spread curve
        Returns:
        the curve
      • getMetadata

        public CurveMetadata getMetadata()
        Description copied from interface: Curve
        Gets the curve metadata.

        This method returns metadata about the curve and the curve parameters.

        For example, a curve may be defined based on financial instruments. The parameters might represent 1 day, 1 week, 1 month, 3 months, 6 months and 12 months. The metadata could be used to describe each parameter in terms of a Period.

        The metadata includes an optional list of parameter metadata. If parameter metadata is present, the size of the list will match the number of parameters of this curve.

        Specified by:
        getMetadata in interface Curve
        Returns:
        the metadata
      • withMetadata

        public AddFixedCurve withMetadata​(CurveMetadata metadata)
        Description copied from interface: Curve
        Returns a new curve with the specified metadata.

        This allows the metadata of the curve to be changed while retaining all other information. If parameter metadata is present, the size of the list must match the number of parameters of this curve.

        Specified by:
        withMetadata in interface Curve
        Parameters:
        metadata - the new metadata for the curve
        Returns:
        the new curve
      • getParameterCount

        public int getParameterCount()
        Description copied from interface: ParameterizedData
        Gets the number of parameters.

        This returns the number of parameters, which can be used to create a loop to access the other methods on this interface.

        Specified by:
        getParameterCount in interface ParameterizedData
        Returns:
        the number of parameters
      • getParameter

        public double getParameter​(int parameterIndex)
        Description copied from interface: ParameterizedData
        Gets the value of the parameter at the specified index.
        Specified by:
        getParameter in interface ParameterizedData
        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        Returns:
        the value of the parameter
      • getParameterMetadata

        public ParameterMetadata getParameterMetadata​(int parameterIndex)
        Description copied from interface: ParameterizedData
        Gets the metadata of the parameter at the specified index.

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

        Specified by:
        getParameterMetadata in interface Curve
        Specified by:
        getParameterMetadata in interface ParameterizedData
        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        Returns:
        the metadata of the parameter
      • withParameter

        public AddFixedCurve withParameter​(int parameterIndex,
                                           double newValue)
        Description copied from interface: ParameterizedData
        Returns a copy of the data with the value at the specified index altered.

        This instance is immutable and unaffected by this method call.

        Specified by:
        withParameter in interface Curve
        Specified by:
        withParameter in interface ParameterizedData
        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        newValue - the new value for the specified parameter
        Returns:
        a parameterized data instance based on this with the specified parameter altered
      • withPerturbation

        public AddFixedCurve withPerturbation​(ParameterPerturbation perturbation)
        Description copied from interface: ParameterizedData
        Returns a perturbed copy of the data.

        The perturbation instance will be invoked once for each parameter in this instance, returning the perturbed value for that parameter. The result of this method is a new instance that is based on those perturbed values.

        This instance is immutable and unaffected by this method call.

        Specified by:
        withPerturbation in interface Curve
        Specified by:
        withPerturbation in interface ParameterizedData
        Parameters:
        perturbation - the perturbation to apply
        Returns:
        a parameterized data instance based on this with the specified perturbation applied
      • yValue

        public double yValue​(double x)
        Description copied from interface: Curve
        Computes the y-value for the specified x-value.
        Specified by:
        yValue in interface Curve
        Parameters:
        x - the x-value to find the y-value for
        Returns:
        the value at the x-value
      • yValueParameterSensitivity

        public UnitParameterSensitivity yValueParameterSensitivity​(double x)
        Description copied from interface: Curve
        Computes the sensitivity of the y-value with respect to the curve parameters.

        This returns an array with one element for each parameter of the curve. The array contains the sensitivity of the y-value at the specified x-value to each parameter.

        Specified by:
        yValueParameterSensitivity in interface Curve
        Parameters:
        x - the x-value at which the parameter sensitivity is computed
        Returns:
        the sensitivity
      • firstDerivative

        public double firstDerivative​(double x)
        Description copied from interface: Curve
        Computes the first derivative of the curve.

        The first derivative is dy/dx.

        Specified by:
        firstDerivative in interface Curve
        Parameters:
        x - the x-value at which the derivative is taken
        Returns:
        the first derivative
      • split

        public ImmutableList<Curve> split()
        Description copied from interface: Curve
        Obtains a list of underlying curves.

        In most cases, the number of underlying curves is 1, thus a list of this curve is returned.

        Specified by:
        split in interface Curve
        Returns:
        the underlying curves
      • withUnderlyingCurve

        public AddFixedCurve withUnderlyingCurve​(int curveIndex,
                                                 Curve curve)
        Description copied from interface: Curve
        Replaces an underlying curve by a new curve.

        curveIndex must be coherent to the index of the list in split().

        Specified by:
        withUnderlyingCurve in interface Curve
        Parameters:
        curveIndex - the curve index
        curve - the new split curve
        Returns:
        the new curve
      • meta

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

        public AddFixedCurve.Meta metaBean()
        Specified by:
        metaBean in interface org.joda.beans.Bean
      • getFixedCurve

        public Curve getFixedCurve()
        Gets the fixed curve. Also called base or shape curve.
        Returns:
        the value of the property, not null
      • getSpreadCurve

        public Curve getSpreadCurve()
        Gets the spread curve. Also called the variable curve.
        Returns:
        the value of the property, not null
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object