Interface Curve
-
- All Superinterfaces:
ParameterizedData
- All Known Subinterfaces:
NodalCurve
- All Known Implementing Classes:
AddFixedCurve,CombinedCurve,ConstantCurve,ConstantNodalCurve,HybridNodalCurve,InflationNodalCurve,InterpolatedNodalCurve,ParallelShiftedCurve,ParameterizedFunctionalCurve
public interface Curve extends ParameterizedData
A curve that maps adoublex-value to adoubley-value.Implementations of this interface provide the ability to find a y-value on the curve from the x-value.
Each implementation will be backed by a number of parameters. The meaning of the parameters is implementation dependent. The sensitivity of the result to each of the parameters can also be obtained.
- See Also:
InterpolatedNodalCurve
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CurrencyParameterSensitivitycreateParameterSensitivity(Currency currency, DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.default UnitParameterSensitivitycreateParameterSensitivity(DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.default OptionalIntfindParameterIndex(ParameterMetadata metadata)Finds the parameter index of the specified metadata.doublefirstDerivative(double x)Computes the first derivative of the curve.CurveMetadatagetMetadata()Gets the curve metadata.default CurveNamegetName()Gets the curve name.default ParameterMetadatagetParameterMetadata(int parameterIndex)Gets the metadata of the parameter at the specified index.default ImmutableList<Curve>split()Obtains a list of underlying curves.CurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.CurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.default CurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.default CurvewithUnderlyingCurve(int curveIndex, Curve curve)Replaces an underlying curve by a new curve.doubleyValue(double x)Computes the y-value for the specified x-value.UnitParameterSensitivityyValueParameterSensitivity(double x)Computes the sensitivity of the y-value with respect to the curve parameters.-
Methods inherited from interface com.opengamma.strata.market.param.ParameterizedData
getParameter, getParameterCount
-
-
-
-
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:ParameterizedDataGets the metadata of the parameter at the specified index.If there is no specific parameter metadata, an empty instance will be returned.
- Specified by:
getParameterMetadatain interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
-
findParameterIndex
default OptionalInt findParameterIndex(ParameterMetadata metadata)
Description copied from interface:ParameterizedDataFinds the parameter index of the specified metadata.If the parameter metadata is not matched, an empty optional will be returned.
- Specified by:
findParameterIndexin interfaceParameterizedData- Parameters:
metadata- the parameter metadata to find the index of- Returns:
- the index of the parameter
-
withParameter
Curve withParameter(int parameterIndex, double newValue)
Description copied from interface:ParameterizedDataReturns 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:
withParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to getnewValue- 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:ParameterizedDataReturns 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:
withPerturbationin interfaceParameterizedData- 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:
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:
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 aUnitParameterSensitivityfrom 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 aCurrencyParameterSensitivityfrom pre-computed sensitivity values.- Parameters:
currency- the currencysensitivities- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
split
default 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.curveIndexmust be coherent to the index of the list insplit().- Parameters:
curveIndex- the curve indexcurve- the new split curve- Returns:
- the new curve
- Throws:
IllegalArgumentException- ifcurveIndexis outside the range
-
-