Interface Curve

    • Method Detail

      • getMetadata

        CurveMetadata getMetadata()
        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.

        Returns:
        the metadata
      • withMetadata

        Curve withMetadata​(CurveMetadata metadata)
        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.

        Parameters:
        metadata - the new metadata for the curve
        Returns:
        the new curve
      • getName

        default CurveName getName()
        Gets the curve name.
        Returns:
        the curve name
      • getParameterMetadata

        default 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 ParameterizedData
        Parameters:
        parameterIndex - the zero-based index of the parameter to get
        Returns:
        the metadata of the parameter
      • withParameter

        Curve 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 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

        default Curve 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 ParameterizedData
        Parameters:
        perturbation - the perturbation to apply
        Returns:
        a parameterized data instance based on this with the specified perturbation applied
      • yValue

        double yValue​(double x)
        Computes the y-value for the specified x-value.
        Parameters:
        x - the x-value to find the y-value for
        Returns:
        the value at the x-value
      • yValueParameterSensitivity

        UnitParameterSensitivity yValueParameterSensitivity​(double x)
        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.

        Parameters:
        x - the x-value at which the parameter sensitivity is computed
        Returns:
        the sensitivity
        Throws:
        java.lang.RuntimeException - if the sensitivity cannot be calculated
      • firstDerivative

        double firstDerivative​(double x)
        Computes the first derivative of the curve.

        The first derivative is dy/dx.

        Parameters:
        x - the x-value at which the derivative is taken
        Returns:
        the first derivative
        Throws:
        java.lang.RuntimeException - if the derivative cannot be calculated
      • createParameterSensitivity

        default UnitParameterSensitivity createParameterSensitivity​(DoubleArray sensitivities)
        Creates a parameter sensitivity instance for this curve when the sensitivity values are known.

        In most cases, yValueParameterSensitivity(double) should be used and manipulated. However, it can be useful to create a UnitParameterSensitivity from pre-computed sensitivity values.

        Parameters:
        sensitivities - the sensitivity values, which must match the parameter count of the curve
        Returns:
        the sensitivity
      • createParameterSensitivity

        default CurrencyParameterSensitivity createParameterSensitivity​(Currency currency,
                                                                        DoubleArray sensitivities)
        Creates a parameter sensitivity instance for this curve when the sensitivity values are known.

        In most cases, yValueParameterSensitivity(double) should be used and manipulated. However, it can be useful to create a CurrencyParameterSensitivity from pre-computed sensitivity values.

        Parameters:
        currency - the currency
        sensitivities - the sensitivity values, which must match the parameter count of the curve
        Returns:
        the sensitivity
      • split

        default com.google.common.collect.ImmutableList<Curve> split()
        Obtains a list of underlying curves.

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

        Returns:
        the underlying curves
      • withUnderlyingCurve

        default Curve withUnderlyingCurve​(int curveIndex,
                                          Curve curve)
        Replaces an underlying curve by a new curve.

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

        Parameters:
        curveIndex - the curve index
        curve - the new split curve
        Returns:
        the new curve
        Throws:
        java.lang.IllegalArgumentException - if curveIndex is outside the range