Class ParallelShiftedCurve
- java.lang.Object
-
- com.opengamma.strata.market.curve.ParallelShiftedCurve
-
- All Implemented Interfaces:
Curve,ParameterizedData,Serializable,org.joda.beans.Bean,org.joda.beans.ImmutableBean
public final class ParallelShiftedCurve extends Object implements Curve, org.joda.beans.ImmutableBean, Serializable
A curve with a parallel shift applied to its y-values.This class decorates another curve and applies an adjustment to the y-values when they are queried. The shift is either absolute or relative.
When the shift is absolute the shift amount is added to the y-value.
When the shift is relative the y-value is scaled by the shift amount. The shift amount is interpreted as a percentage. For example, a shift amount of 0.1 is a shift of +10% which multiplies the value by 1.1. A shift amount of -0.2 is a shift of -20% which multiplies the value by 0.8.
The parameters consist of the parameters of the underlying curve, followed by the shift.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classParallelShiftedCurve.MetaThe meta-bean forParallelShiftedCurve.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ParallelShiftedCurveabsolute(Curve curve, double shiftAmount)Returns a curve based on an underlying curve with a fixed amount added to the Y values.booleanequals(Object obj)doublefirstDerivative(double x)Computes the first derivative of the curve.CurveMetadatagetMetadata()Gets the curve metadata.CurveNamegetName()Gets the curve name.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.ParameterMetadatagetParameterMetadata(int parameterIndex)Gets the metadata of the parameter at the specified index.doublegetShiftAmount()Gets the amount by which y-values are shifted.ShiftTypegetShiftType()Gets the type of shift to apply to the y-values of the curve.CurvegetUnderlyingCurve()Gets the underlying curve.inthashCode()static ParallelShiftedCurve.Metameta()The meta-bean forParallelShiftedCurve.ParallelShiftedCurve.MetametaBean()static ParallelShiftedCurveof(Curve curve, ShiftType shiftType, double shiftAmount)Returns a curve based on an underlying curve with a parallel shift applied to the Y values.static ParallelShiftedCurverelative(Curve curve, double shiftAmount)Returns a curve based on an underlying curve with a scaling applied to the Y values.StringtoString()ParallelShiftedCurvewithMetadata(CurveMetadata metadata)Returns a new curve with the specified metadata.ParallelShiftedCurvewithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.ParallelShiftedCurvewithPerturbation(ParameterPerturbation perturbation)Returns a perturbed copy of the data.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
createParameterSensitivity, createParameterSensitivity, findParameterIndex, split, withUnderlyingCurve
-
-
-
-
Method Detail
-
absolute
public static ParallelShiftedCurve absolute(Curve curve, double shiftAmount)
Returns a curve based on an underlying curve with a fixed amount added to the Y values.- Parameters:
curve- the underlying curveshiftAmount- the amount added to the Y values of the curve- Returns:
- a curve based on an underlying curve with a fixed amount added to the Y values.
-
relative
public static ParallelShiftedCurve relative(Curve curve, double shiftAmount)
Returns a curve based on an underlying curve with a scaling applied to the Y values.The shift amount is interpreted as a percentage. For example, a shift amount of 0.1 is a shift of +10% which multiplies the value by 1.1. A shift amount of -0.2 is a shift of -20% which multiplies the value by 0.8
- Parameters:
curve- the underlying curveshiftAmount- the percentage by which the Y values are scaled- Returns:
- a curve based on an underlying curve with a scaling applied to the Y values.
-
of
public static ParallelShiftedCurve of(Curve curve, ShiftType shiftType, double shiftAmount)
Returns a curve based on an underlying curve with a parallel shift applied to the Y values.- Parameters:
curve- the underlying curveshiftType- the type of shift which specifies how the shift amount is applied to the Y valuesshiftAmount- the magnitude of the shift- Returns:
- a curve based on an underlying curve with a parallel shift applied to 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
-
withMetadata
public ParallelShiftedCurve withMetadata(CurveMetadata metadata)
Description copied from interface:CurveReturns 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- Parameters:
metadata- the new metadata for the curve- Returns:
- the new 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
-
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
-
getParameterMetadata
public 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 interfaceCurve- Specified by:
getParameterMetadatain interfaceParameterizedData- Parameters:
parameterIndex- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
-
withParameter
public ParallelShiftedCurve 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 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 ParallelShiftedCurve 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 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:CurveComputes the y-value for the specified x-value.
-
yValueParameterSensitivity
public UnitParameterSensitivity yValueParameterSensitivity(double x)
Description copied from interface:CurveComputes 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:
yValueParameterSensitivityin 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: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
-
meta
public static ParallelShiftedCurve.Meta meta()
The meta-bean forParallelShiftedCurve.- Returns:
- the meta-bean, not null
-
metaBean
public ParallelShiftedCurve.Meta metaBean()
- Specified by:
metaBeanin interfaceorg.joda.beans.Bean
-
getUnderlyingCurve
public Curve getUnderlyingCurve()
Gets the underlying curve.- Returns:
- the value of the property, not null
-
getShiftType
public ShiftType getShiftType()
Gets the type of shift to apply to the y-values of the curve. The amount of the shift is determined by#getShiftAmount().- Returns:
- the value of the property, not null
-
getShiftAmount
public double getShiftAmount()
Gets the amount by which y-values are shifted. The meaning of this amount is determined by#getShiftType().- Returns:
- the value of the property, not null
-
-