Class HybridNodalCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.HybridNodalCurve
-
- All Implemented Interfaces:
Curve,NodalCurve,ParameterizedData,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class HybridNodalCurve extends Object implements NodalCurve, org.joda.beans.ImmutableBean, Serializable
A hybrid curve which combines two underlying nodal curves, allowing different interpolators to be used for different parts of the curve.The left curve is used for all points up to and including a certain x-value, the right curve is used for higher x-values.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHybridNodalCurve.MetaThe meta-bean forHybridNodalCurve.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CurrencyParameterSensitivitycreateParameterSensitivity(Currency currency, DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.UnitParameterSensitivitycreateParameterSensitivity(DoubleArray sensitivities)Creates a parameter sensitivity instance for this curve when the sensitivity values are known.booleanequals(Object obj)doublefirstDerivative(double x)Computes the first derivative of the curve.NodalCurvegetLeftCurve()Gets the left nodal curve.CurveMetadatagetMetadata()Gets the curve metadata.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.NodalCurvegetRightCurve()Gets the right nodal curve.DoubleArraygetXValues()Gets the known x-values of the curve.DoubleArraygetYValues()Gets the known y-values of the curve.inthashCode()static HybridNodalCurve.Metameta()The meta-bean forHybridNodalCurve.HybridNodalCurve.MetametaBean()static HybridNodalCurveof(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, int spliceIndex, CurveInterpolator interpolatorLeft, CurveInterpolator interpolatorRight, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)Create a new hybrid nodal curve.StringtoString()HybridNodalCurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.HybridNodalCurvewithNode(double x, double y, ParameterMetadata paramMetadata)Returns a new curve with an additional node, specifying the parameter metadata.HybridNodalCurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.HybridNodalCurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.HybridNodalCurvewithValues(DoubleArray xValues, DoubleArray yValues)Returns a new curve with the specified x-values and y-values.HybridNodalCurvewithYValues(DoubleArray yValues)Returns a new curve with the specified values.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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.curve.Curve
findParameterIndex, getName, split, withUnderlyingCurve
-
Methods inherited from interface com.opengamma.strata.market.curve.NodalCurve
getParameterMetadata, values
-
-
-
-
Method Detail
-
of
public static HybridNodalCurve of(CurveMetadata metadata, DoubleArray xValues, DoubleArray yValues, int spliceIndex, CurveInterpolator interpolatorLeft, CurveInterpolator interpolatorRight, CurveExtrapolator extrapolatorLeft, CurveExtrapolator extrapolatorRight)
Create a new hybrid nodal curve.- Parameters:
metadata- the common metadata, containing parameter metadata for all of the valuesxValues- the full set of x valuesyValues- the full set of y valuesspliceIndex- the x index at which the curves should be splitinterpolatorLeft- the interpolator for the left curveinterpolatorRight- the interpolator for the right curveextrapolatorLeft- the extrapolator for x-values less than the smallest defined x-valueextrapolatorRight- the extrapolator for x-values greater than the largest defined x-value- Returns:
- the hybrid nodal curve
-
getParameterCount
public int getParameterCount()
Description copied from interface:ParameterizedDataGets 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:
getParameterCountin interfaceParameterizedData- Returns:
- the number of parameters
-
getXValues
public DoubleArray getXValues()
Description copied from interface:NodalCurveGets the known x-values of the curve.This method returns the fixed x-values used to define the curve. This will be of the same size as the y-values.
- Specified by:
getXValuesin interfaceNodalCurve- Returns:
- the x-values
-
getYValues
public DoubleArray getYValues()
Description copied from interface:NodalCurveGets the known y-values of the curve.This method returns the fixed y-values used to define the curve. This will be of the same size as the x-values.
- Specified by:
getYValuesin interfaceNodalCurve- Returns:
- the y-values
-
getMetadata
public CurveMetadata getMetadata()
Description copied from interface:CurveGets 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:
getMetadatain interfaceCurve- Returns:
- the metadata
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedDataGets the value of the parameter at the specified index.- Specified by:
getParameterin interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to get- Returns:
- the value of the parameter
-
yValue
public double yValue(double x)
Description copied from interface:CurveComputes the y-value for the specified x-value.
-
yValueParameterSensitivity
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Computes the sensitivity of the y-value with respect to the curve parametersThe result will be UnitParameterSensitivity, which stores the sensitivity in a DoubleArray of size getParameterCount()
If x<= xSplice, then sensitive to all nodes from 0 to spliceIndex, with zero sensitivity to all nodes from spliceIndex+1 to getParameterCount()-1
If x > xSplice, then sensitive to all nodes from spliceIndex to getParameterCount()-1, with zero sensitivity to all nodes from 0 to spliceIndex-1
- Specified by:
yValueParameterSensitivityin interfaceCurve- Parameters:
x- the new x-value- Returns:
- the unit parameter sensitivity
-
firstDerivative
public double firstDerivative(double x)
Description copied from interface:CurveComputes the first derivative of the curve.The first derivative is
dy/dx.- Specified by:
firstDerivativein interfaceCurve- Parameters:
x- the x-value at which the derivative is taken- Returns:
- the first derivative
-
withNode
public HybridNodalCurve withNode(double x, double y, ParameterMetadata paramMetadata)
Description copied from interface:NodalCurveReturns a new curve with an additional node, specifying the parameter metadata.The result will contain the specified node. If the x-value equals an existing x-value, the y-value will be changed. If the x-value does not equal an existing x-value, the node will be added.
The result will only contain the specified parameter metadata if this curve also has parameter meta-data.
- Specified by:
withNodein interfaceNodalCurve- Parameters:
x- the new x-valuey- the new y-valueparamMetadata- the new parameter metadata- Returns:
- the updated curve
-
withYValues
public HybridNodalCurve withYValues(DoubleArray yValues)
Description copied from interface:NodalCurveReturns a new curve with the specified values.This allows the y-values of the curve to be changed while retaining the same x-values.
- Specified by:
withYValuesin interfaceNodalCurve- Parameters:
yValues- the new y-values for the curve- Returns:
- the new curve
-
withMetadata
public HybridNodalCurve withMetadata(CurveMetadata metadata)
Description copied from interface:NodalCurveReturns 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:
withMetadatain interfaceCurve- Specified by:
withMetadatain interfaceNodalCurve- Parameters:
metadata- the new metadata for the curve- Returns:
- the new curve
-
withParameter
public HybridNodalCurve 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 interfaceCurve- Specified by:
withParameterin interfaceNodalCurve- 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
-
createParameterSensitivity
public UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Description copied from interface:CurveCreates a parameter sensitivity instance for this curve when the sensitivity values are known.In most cases,
Curve.yValueParameterSensitivity(double)should be used and manipulated. However, it can be useful to create aUnitParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin interfaceCurve- Parameters:
sensitivities- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
createParameterSensitivity
public CurrencyParameterSensitivity createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Description copied from interface:CurveCreates a parameter sensitivity instance for this curve when the sensitivity values are known.In most cases,
Curve.yValueParameterSensitivity(double)should be used and manipulated. However, it can be useful to create aCurrencyParameterSensitivityfrom pre-computed sensitivity values.- Specified by:
createParameterSensitivityin interfaceCurve- Parameters:
currency- the currencysensitivities- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
withPerturbation
public HybridNodalCurve 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 interfaceCurve- Specified by:
withPerturbationin interfaceNodalCurve- Specified by:
withPerturbationin interfaceParameterizedData- Parameters:
perturbation- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
withValues
public HybridNodalCurve withValues(DoubleArray xValues, DoubleArray yValues)
Description copied from interface:NodalCurveReturns a new curve with the specified x-values and y-values.This allows the x values and y-values of the curve to be changed.
- Specified by:
withValuesin interfaceNodalCurve- Parameters:
xValues- the new x-values for the curveyValues- the new y-values for the curve- Returns:
- the new curve
-
meta
public static HybridNodalCurve.Meta meta()
The meta-bean forHybridNodalCurve.- Returns:
- the meta-bean, not null
-
metaBean
public HybridNodalCurve.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getLeftCurve
public NodalCurve getLeftCurve()
Gets the left nodal curve.- Returns:
- the value of the property, not null
-
getRightCurve
public NodalCurve getRightCurve()
Gets the right nodal curve.- Returns:
- the value of the property, not null
-
-