Class SimplePriceIndexValues
- java.lang.Object
-
- com.opengamma.strata.pricer.rate.SimplePriceIndexValues
-
- All Implemented Interfaces:
MarketDataView
,ParameterizedData
,PriceIndexValues
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class SimplePriceIndexValues extends Object implements PriceIndexValues, org.joda.beans.ImmutableBean, Serializable
Provides values for a Price index from a forward curve.This provides historic and forward rates for a single
PriceIndex
, such as 'US-CPI-U'.This implementation is based on an underlying forward curve. Seasonality is included in the curve, see
InflationNodalCurve
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SimplePriceIndexValues.Meta
The meta-bean forSimplePriceIndexValues
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CurrencyParameterSensitivities
createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Creates the parameter sensitivity when the sensitivity values are known.boolean
equals(Object obj)
<T> Optional<T>
findData(MarketDataName<T> name)
Finds the market data with the specified name.OptionalInt
findParameterIndex(ParameterMetadata metadata)
Finds the parameter index of the specified metadata.Curve
getCurve()
Gets the underlying curve.LocalDateDoubleTimeSeries
getFixings()
Gets the monthly time-series of fixings.PriceIndex
getIndex()
Gets the index that the values are for.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.LocalDate
getValuationDate()
Gets the valuation date.int
hashCode()
static SimplePriceIndexValues.Meta
meta()
The meta-bean forSimplePriceIndexValues
.SimplePriceIndexValues.Meta
metaBean()
static SimplePriceIndexValues
of(PriceIndex index, LocalDate valuationDate, Curve curve, LocalDateDoubleTimeSeries fixings)
Obtains an instance based on a curve with no seasonality adjustment.CurrencyParameterSensitivities
parameterSensitivity(InflationRateSensitivity pointSensitivity)
Calculates the parameter sensitivity from the point sensitivity.String
toString()
double
value(PriceIndexObservation observation)
Gets the historic or forward rate at the specified fixing month.PointSensitivityBuilder
valuePointSensitivity(PriceIndexObservation observation)
Calculates the point sensitivity of the historic or forward value at the specified fixing month.SimplePriceIndexValues
withCurve(Curve curve)
Returns a new instance with a different curve.SimplePriceIndexValues
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.SimplePriceIndexValues
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
-
-
-
Method Detail
-
of
public static SimplePriceIndexValues of(PriceIndex index, LocalDate valuationDate, Curve curve, LocalDateDoubleTimeSeries fixings)
Obtains an instance based on a curve with no seasonality adjustment.Each x-value on the curve is the number of months between the valuation month and the estimation month. For example, zero represents the valuation month, one the next month and so on.
The time-series contains one value per month and must have at least one entry. The value is stored in the time-series on the last date of each month (which may be a non-working day).
The curve will be altered to be consistent with the time-series. The last element of the series is added as the first point of the interpolated curve to ensure a coherent transition.
- Parameters:
index
- the Price indexvaluationDate
- the valuation date for which the curve is validfixings
- the time-series of fixingscurve
- the underlying forward curve for index estimation- Returns:
- the values instance
-
findData
public <T> Optional<T> findData(MarketDataName<T> name)
Description copied from interface:MarketDataView
Finds the market data with the specified name.This is most commonly used to find an underlying curve or surface by name. If the market data cannot be found, empty is returned.
- Specified by:
findData
in interfaceMarketDataView
- Type Parameters:
T
- the type of the market data value- Parameters:
name
- the name to find- Returns:
- the market data value, empty if not found
-
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 interfaceParameterizedData
- Parameters:
parameterIndex
- the zero-based index of the parameter to get- Returns:
- the metadata of the parameter
-
findParameterIndex
public 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
public SimplePriceIndexValues 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
- Specified by:
withParameter
in interfacePriceIndexValues
- 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 SimplePriceIndexValues 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
- Specified by:
withPerturbation
in interfacePriceIndexValues
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
value
public double value(PriceIndexObservation observation)
Description copied from interface:PriceIndexValues
Gets the historic or forward rate at the specified fixing month.The rate of the Price index, such as 'US-CPI-U', varies over time. This method obtains the actual or estimated rate for the month.
This retrieves the actual rate if the fixing month is before the valuation month, or the estimated rate if the fixing month is after the valuation month. If the month equals the valuation month, then the best available value is returned.
- Specified by:
value
in interfacePriceIndexValues
- Parameters:
observation
- the rate observation, including the fixing month- Returns:
- the value of the index, either historic or forward
-
valuePointSensitivity
public PointSensitivityBuilder valuePointSensitivity(PriceIndexObservation observation)
Description copied from interface:PriceIndexValues
Calculates the point sensitivity of the historic or forward value at the specified fixing month.This returns a sensitivity instance referring to the points that were queried in the market data. If a time-series was used, then there is no sensitivity. The sensitivity refers to the result of
PriceIndexValues.value(PriceIndexObservation)
.- Specified by:
valuePointSensitivity
in interfacePriceIndexValues
- Parameters:
observation
- the rate observation, including the fixing month- Returns:
- the point sensitivity of the value
-
parameterSensitivity
public CurrencyParameterSensitivities parameterSensitivity(InflationRateSensitivity pointSensitivity)
Description copied from interface:PriceIndexValues
Calculates the parameter sensitivity from the point sensitivity.This is used to convert a single point sensitivity to parameter sensitivity. The calculation typically involves multiplying the point and unit sensitivities.
- Specified by:
parameterSensitivity
in interfacePriceIndexValues
- Parameters:
pointSensitivity
- the point sensitivity to convert- Returns:
- the parameter sensitivity
-
createParameterSensitivity
public CurrencyParameterSensitivities createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Description copied from interface:PriceIndexValues
Creates the parameter sensitivity when the sensitivity values are known.In most cases,
PriceIndexValues.parameterSensitivity(InflationRateSensitivity)
should be used and manipulated. However, it can be useful to create parameter sensitivity from pre-computed sensitivity values.There will typically be one
CurrencyParameterSensitivity
for each underlying data structure, such as a curve. For example, if the values are based on a single forward curve, then there will be oneCurrencyParameterSensitivity
in the result.- Specified by:
createParameterSensitivity
in interfacePriceIndexValues
- Parameters:
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count- Returns:
- the parameter sensitivity
-
withCurve
public SimplePriceIndexValues withCurve(Curve curve)
Returns a new instance with a different curve. The new curve must include fixing.- Parameters:
curve
- the new curve- Returns:
- the new instance
-
meta
public static SimplePriceIndexValues.Meta meta()
The meta-bean forSimplePriceIndexValues
.- Returns:
- the meta-bean, not null
-
metaBean
public SimplePriceIndexValues.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getIndex
public PriceIndex getIndex()
Gets the index that the values are for.- Specified by:
getIndex
in interfacePriceIndexValues
- Returns:
- the value of the property, not null
-
getValuationDate
public LocalDate getValuationDate()
Gets the valuation date.- Specified by:
getValuationDate
in interfaceMarketDataView
- Returns:
- the value of the property, not null
-
getCurve
public Curve getCurve()
Gets the underlying curve. Each x-value on the curve is the number of months between the valuation month and the estimation month. For example, zero represents the valuation month, one the next month and so on.- Returns:
- the value of the property, not null
-
getFixings
public LocalDateDoubleTimeSeries getFixings()
Gets the monthly time-series of fixings. This includes the known historical fixings and must not be empty.Only one value is stored per month. The value is stored in the time-series on the last date of each month (which may be a non-working day).
- Specified by:
getFixings
in interfacePriceIndexValues
- Returns:
- the value of the property, not null
-
-