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 adouble
x-value to adouble
y-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 CurrencyParameterSensitivity
createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.default UnitParameterSensitivity
createParameterSensitivity(DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.default OptionalInt
findParameterIndex(ParameterMetadata metadata)
Finds the parameter index of the specified metadata.double
firstDerivative(double x)
Computes the first derivative of the curve.CurveMetadata
getMetadata()
Gets the curve metadata.default CurveName
getName()
Gets the curve name.default ParameterMetadata
getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.default ImmutableList<Curve>
split()
Obtains a list of underlying curves.Curve
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.Curve
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.default Curve
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.default Curve
withUnderlyingCurve(int curveIndex, Curve curve)
Replaces an underlying curve by a new curve.double
yValue(double x)
Computes the y-value for the specified x-value.UnitParameterSensitivity
yValueParameterSensitivity(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: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 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:ParameterizedData
Finds the parameter index of the specified metadata.If the parameter metadata is not matched, an empty optional will be returned.
- Specified by:
findParameterIndex
in 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: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 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: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 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 aUnitParameterSensitivity
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 aCurrencyParameterSensitivity
from 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.curveIndex
must be coherent to the index of the list insplit()
.- Parameters:
curveIndex
- the curve indexcurve
- the new split curve- Returns:
- the new curve
- Throws:
IllegalArgumentException
- ifcurveIndex
is outside the range
-
-