Class CombinedCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.CombinedCurve
-
- All Implemented Interfaces:
Curve
,ParameterizedData
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class CombinedCurve extends Object implements Curve, org.joda.beans.ImmutableBean, Serializable
A curve formed from two curves, the base curve and the spread curve.The parameters of this curve are the combination of the base curve parameters and spread curve parameters. The node sensitivities are calculated in terms of the nodes on the base curve and spread curve.
If one of the two curves must be fixed, use
AddFixedCurve
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CombinedCurve.Meta
The meta-bean forCombinedCurve
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CurrencyParameterSensitivity
createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.UnitParameterSensitivity
createParameterSensitivity(DoubleArray sensitivities)
Creates a parameter sensitivity instance for this curve when the sensitivity values are known.boolean
equals(Object obj)
double
firstDerivative(double x)
Computes the first derivative of the curve.Curve
getBaseCurve()
Gets the base curve.CurveMetadata
getMetadata()
Gets the curve metadata.double
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.int
getParameterCount()
Gets the number of parameters.ParameterMetadata
getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.Curve
getSpreadCurve()
Gets the spread curve.int
hashCode()
static CombinedCurve.Meta
meta()
The meta-bean forCombinedCurve
.CombinedCurve.Meta
metaBean()
static CombinedCurve
of(Curve baseCurve, Curve spreadCurve)
Creates a curve as the sum of a base curve and a spread curve.static CombinedCurve
of(Curve baseCurve, Curve spreadCurve, CurveMetadata metadata)
Creates a curve as the sum of a base curve and a spread curve with a specified curve metadata.ImmutableList<Curve>
split()
Obtains a list of underlying curves.String
toString()
CombinedCurve
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.CombinedCurve
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.CombinedCurve
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.CombinedCurve
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 class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.curve.Curve
findParameterIndex, getName
-
-
-
-
Method Detail
-
of
public static CombinedCurve of(Curve baseCurve, Curve spreadCurve, CurveMetadata metadata)
Creates a curve as the sum of a base curve and a spread curve with a specified curve metadata.- Parameters:
baseCurve
- the base curvespreadCurve
- the spread curvemetadata
- the metadata- Returns:
- the combined curve
-
of
public static CombinedCurve of(Curve baseCurve, Curve spreadCurve)
Creates a curve as the sum of a base curve and a spread curve.The metadata of the combined curve will be created form the base curve and spread curve.
- Parameters:
baseCurve
- the base curvespreadCurve
- the spread curve- Returns:
- the combined curve
-
withMetadata
public CombinedCurve 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 interfaceCurve
- 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 interfaceParameterizedData
- 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 interfaceParameterizedData
- 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 interfaceCurve
- Specified by:
getParameterMetadata
in interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
-
withParameter
public CombinedCurve 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 interfaceCurve
- 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
public CombinedCurve 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 interfaceCurve
- 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
public double yValue(double x)
Description copied from interface:Curve
Computes the y-value for the specified 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 interfaceCurve
- 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 interfaceCurve
- Parameters:
x
- the x-value at which the derivative is taken- Returns:
- the first derivative
-
createParameterSensitivity
public UnitParameterSensitivity createParameterSensitivity(DoubleArray sensitivities)
Description copied from interface:Curve
Creates 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 aUnitParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in 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:Curve
Creates 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 aCurrencyParameterSensitivity
from pre-computed sensitivity values.- Specified by:
createParameterSensitivity
in interfaceCurve
- Parameters:
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count of the curve- Returns:
- the sensitivity
-
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.
-
withUnderlyingCurve
public CombinedCurve 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 insplit()
.- Specified by:
withUnderlyingCurve
in interfaceCurve
- Parameters:
curveIndex
- the curve indexcurve
- the new split curve- Returns:
- the new curve
-
meta
public static CombinedCurve.Meta meta()
The meta-bean forCombinedCurve
.- Returns:
- the meta-bean, not null
-
metaBean
public CombinedCurve.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getBaseCurve
public Curve getBaseCurve()
Gets the base curve.- Returns:
- the value of the property, not null
-
getSpreadCurve
public Curve getSpreadCurve()
Gets the spread curve.- Returns:
- the value of the property, not null
-
getMetadata
public CurveMetadata getMetadata()
Gets the curve metadata.- Specified by:
getMetadata
in interfaceCurve
- Returns:
- the value of the property, not null
-
-