public final class ParallelShiftedCurve extends Object implements Curve, org.joda.beans.ImmutableBean, Serializable
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.
| Modifier and Type | Class and Description |
|---|---|
static class |
ParallelShiftedCurve.Meta
The meta-bean for
ParallelShiftedCurve. |
| Modifier and Type | Method and Description |
|---|---|
static ParallelShiftedCurve |
absolute(Curve curve,
double shiftAmount)
Returns a curve based on an underlying curve with a fixed amount added to the Y values.
|
boolean |
equals(Object obj) |
double |
firstDerivative(double x)
Computes the first derivative of the curve.
|
CurveMetadata |
getMetadata()
Gets the curve metadata.
|
CurveName |
getName()
Gets the curve name.
|
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.
|
double |
getShiftAmount()
Gets the amount by which y-values are shifted.
|
ShiftType |
getShiftType()
Gets the type of shift to apply to the y-values of the curve.
|
Curve |
getUnderlyingCurve()
Gets the underlying curve.
|
int |
hashCode() |
static ParallelShiftedCurve.Meta |
meta()
The meta-bean for
ParallelShiftedCurve. |
ParallelShiftedCurve.Meta |
metaBean() |
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.
|
static ParallelShiftedCurve |
relative(Curve curve,
double shiftAmount)
Returns a curve based on an underlying curve with a scaling applied to the Y values.
|
String |
toString() |
ParallelShiftedCurve |
withMetadata(CurveMetadata metadata)
Returns a new curve with the specified metadata.
|
ParallelShiftedCurve |
withParameter(int parameterIndex,
double newValue)
Returns a copy of the data with the value at the specified index altered.
|
ParallelShiftedCurve |
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
|
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitcreateParameterSensitivity, createParameterSensitivity, findParameterIndex, split, withUnderlyingCurvepublic static ParallelShiftedCurve absolute(Curve curve, double shiftAmount)
curve - the underlying curveshiftAmount - the amount added to the Y values of the curvepublic static ParallelShiftedCurve relative(Curve curve, double shiftAmount)
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
curve - the underlying curveshiftAmount - the percentage by which the Y values are scaledpublic static ParallelShiftedCurve of(Curve curve, ShiftType shiftType, double shiftAmount)
curve - the underlying curveshiftType - the type of shift which specifies how the shift amount is applied to the Y valuesshiftAmount - the magnitude of the shiftpublic CurveMetadata getMetadata()
CurveThis 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.
getMetadata in interface Curvepublic ParallelShiftedCurve withMetadata(CurveMetadata metadata)
CurveThis 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.
withMetadata in interface Curvemetadata - the new metadata for the curvepublic int getParameterCount()
ParameterizedDataThis returns the number of parameters, which can be used to create a loop to access the other methods on this interface.
getParameterCount in interface ParameterizedDatapublic double getParameter(int parameterIndex)
ParameterizedDatagetParameter in interface ParameterizedDataparameterIndex - the zero-based index of the parameter to getpublic ParameterMetadata getParameterMetadata(int parameterIndex)
ParameterizedDataIf there is no specific parameter metadata, an empty instance will be returned.
getParameterMetadata in interface CurvegetParameterMetadata in interface ParameterizedDataparameterIndex - the zero-based index of the parameter to getpublic ParallelShiftedCurve withParameter(int parameterIndex, double newValue)
ParameterizedDataThis instance is immutable and unaffected by this method call.
withParameter in interface CurvewithParameter in interface ParameterizedDataparameterIndex - the zero-based index of the parameter to getnewValue - the new value for the specified parameterpublic ParallelShiftedCurve withPerturbation(ParameterPerturbation perturbation)
ParameterizedDataThe 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.
withPerturbation in interface CurvewithPerturbation in interface ParameterizedDataperturbation - the perturbation to applypublic double yValue(double x)
Curvepublic UnitParameterSensitivity yValueParameterSensitivity(double x)
CurveThis 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.
yValueParameterSensitivity in interface Curvex - the x-value at which the parameter sensitivity is computedpublic double firstDerivative(double x)
Curve
The first derivative is dy/dx.
firstDerivative in interface Curvex - the x-value at which the derivative is takenpublic static ParallelShiftedCurve.Meta meta()
ParallelShiftedCurve.public ParallelShiftedCurve.Meta metaBean()
metaBean in interface org.joda.beans.Beanpublic Curve getUnderlyingCurve()
public ShiftType getShiftType()
#getShiftAmount().public double getShiftAmount()
#getShiftType().Copyright 2009-Present by OpenGamma Inc. and individual contributors
Apache v2 licensed
Additional documentation can be found at strata.opengamma.io.