Class ZeroRatePeriodicDiscountFactors

• All Implemented Interfaces:
MarketDataView, ParameterizedData, DiscountFactors, Serializable, org.joda.beans.Bean, org.joda.beans.ImmutableBean

public final class ZeroRatePeriodicDiscountFactors
extends Object
implements DiscountFactors, org.joda.beans.ImmutableBean, Serializable
Provides access to discount factors for a currency based on a zero rate periodically-compounded curve.

This provides discount factors for a single currency.

This implementation is based on an underlying curve that is stored with maturities and zero-coupon periodically-compounded rates.

Serialized Form
• Nested Class Summary

Nested Classes
Modifier and Type Class Description
static class  ZeroRatePeriodicDiscountFactors.Meta
The meta-bean for ZeroRatePeriodicDiscountFactors.
• Method Summary

All Methods
Modifier and Type Method Description
CurrencyParameterSensitivities createParameterSensitivity​(Currency currency, DoubleArray sensitivities)
Creates the parameter sensitivity when the sensitivity values are known.
double discountFactor​(double relativeYearFraction)
Gets the discount factor for specified year fraction.
double discountFactorTimeDerivative​(double yearFraction)
Returns the discount factor derivative with respect to the year fraction or time.
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.
Currency getCurrency()
Gets the currency that the discount factors are for.
Curve getCurve()
Gets the underlying curve.
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 ZeroRatePeriodicDiscountFactors.Meta meta()
The meta-bean for ZeroRatePeriodicDiscountFactors.
ZeroRatePeriodicDiscountFactors.Meta metaBean()
static ZeroRatePeriodicDiscountFactors of​(Currency currency, LocalDate valuationDate, Curve underlyingCurve)
Obtains an instance based on a zero-rates curve.
CurrencyParameterSensitivities parameterSensitivity​(ZeroRateSensitivity pointSens)
Calculates the parameter sensitivity from the point sensitivity.
double relativeYearFraction​(LocalDate date)
Calculates the relative time between the valuation date and the specified date.
String toString()
ZeroRatePeriodicDiscountFactors withCurve​(Curve curve)
Returns a new instance with a different curve.
ZeroRatePeriodicDiscountFactors withParameter​(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.
ZeroRatePeriodicDiscountFactors withPerturbation​(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
double zeroRate​(double yearFraction)
Gets the continuously compounded zero rate for specified year fraction.
ZeroRateSensitivity zeroRatePointSensitivity​(double yearFraction, Currency sensitivityCurrency)
Calculates the zero rate point sensitivity at the specified year fraction specifying the currency of the sensitivity.
ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction, Currency sensitivityCurrency, double zSpread, CompoundedRateType compoundedRateType, int periodPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified year fraction specifying the currency of the sensitivity.
• Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• Methods inherited from interface org.joda.beans.Bean

property, propertyNames
• Methods inherited from interface com.opengamma.strata.pricer.DiscountFactors

discountFactor, discountFactorWithSpread, discountFactorWithSpread, zeroRate, zeroRatePointSensitivity, zeroRatePointSensitivity, zeroRatePointSensitivity, zeroRatePointSensitivityWithSpread, zeroRatePointSensitivityWithSpread, zeroRatePointSensitivityWithSpread
• Method Detail

• of

public static ZeroRatePeriodicDiscountFactors of​(Currency currency,
LocalDate valuationDate,
Curve underlyingCurve)
Obtains an instance based on a zero-rates curve.

The curve is specified by an instance of Curve, such as InterpolatedNodalCurve. The curve must contain year fractions against zero rates. The day count and compounding periods per year must be present in the metadata.

Parameters:
currency - the currency
valuationDate - the valuation date for which the curve is valid
underlyingCurve - the underlying curve
Returns:
the curve
• 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 interface MarketDataView
Type Parameters:
T - the type of the market data value
Parameters:
name - the name to find
Returns:
• 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 interface ParameterizedData
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 interface ParameterizedData
Parameters:
parameterIndex - the zero-based index of the parameter to get
Returns:
the value of the parameter

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 interface ParameterizedData
Parameters:
parameterIndex - the zero-based index of the parameter to get
Returns:
• 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 interface ParameterizedData
Parameters:
metadata - the parameter metadata to find the index of
Returns:
the index of the parameter
• withParameter

public ZeroRatePeriodicDiscountFactors 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 interface DiscountFactors
Specified by:
withParameter in interface ParameterizedData
Parameters:
parameterIndex - the zero-based index of the parameter to get
newValue - the new value for the specified parameter
Returns:
a parameterized data instance based on this with the specified parameter altered
• withPerturbation

public ZeroRatePeriodicDiscountFactors 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 interface DiscountFactors
Specified by:
withPerturbation in interface ParameterizedData
Parameters:
perturbation - the perturbation to apply
Returns:
a parameterized data instance based on this with the specified perturbation applied
• relativeYearFraction

public double relativeYearFraction​(LocalDate date)
Description copied from interface: DiscountFactors
Calculates the relative time between the valuation date and the specified date.

The double value returned from this method is used as the input to other methods. It is typically calculated from a DayCount.

Specified by:
relativeYearFraction in interface DiscountFactors
Parameters:
date - the date
Returns:
the year fraction
• discountFactor

public double discountFactor​(double relativeYearFraction)
Description copied from interface: DiscountFactors
Gets the discount factor for specified year fraction.

The year fraction must be based on #relativeYearFraction(LocalDate).

Specified by:
discountFactor in interface DiscountFactors
Parameters:
relativeYearFraction - the year fraction
Returns:
the discount factor
• discountFactorTimeDerivative

public double discountFactorTimeDerivative​(double yearFraction)
Description copied from interface: DiscountFactors
Returns the discount factor derivative with respect to the year fraction or time.

The year fraction must be based on #relativeYearFraction(LocalDate).

Specified by:
discountFactorTimeDerivative in interface DiscountFactors
Parameters:
yearFraction - the year fraction
Returns:
the discount factor derivative
• zeroRate

public double zeroRate​(double yearFraction)
Description copied from interface: DiscountFactors
Gets the continuously compounded zero rate for specified year fraction.

The year fraction must be based on #relativeYearFraction(LocalDate).

Specified by:
zeroRate in interface DiscountFactors
Parameters:
yearFraction - the year fraction
Returns:
the zero rate
• zeroRatePointSensitivity

public ZeroRateSensitivity zeroRatePointSensitivity​(double yearFraction,
Currency sensitivityCurrency)
Description copied from interface: DiscountFactors
Calculates the zero rate point sensitivity at the specified year fraction specifying the currency of the sensitivity.

This returns a sensitivity instance referring to the zero rate sensitivity of the points that were queried in the market data. The sensitivity typically has the value (-discountFactor * yearFraction). The sensitivity refers to the result of DiscountFactors.discountFactor(LocalDate).

This method allows the currency of the sensitivity to differ from the currency of the market data.

The year fraction must be based on #relativeYearFraction(LocalDate).

Specified by:
zeroRatePointSensitivity in interface DiscountFactors
Parameters:
yearFraction - the year fraction
sensitivityCurrency - the currency of the sensitivity
Returns:
the point sensitivity of the zero rate

public ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction,
Currency sensitivityCurrency,
CompoundedRateType compoundedRateType,
int periodPerYear)
Description copied from interface: DiscountFactors
Calculates the zero rate point sensitivity with z-spread at the specified year fraction specifying the currency of the sensitivity.

This returns a sensitivity instance referring to the zero rate sensitivity of the points that were queried in the market data. The sensitivity refers to the result of DiscountFactors.discountFactorWithSpread(LocalDate, double, CompoundedRateType, int).

The z-spread is a parallel shift applied to continuously compounded rates or periodic compounded rates of the discounting curve.

This method allows the currency of the sensitivity to differ from the currency of the market data.

The year fraction must be based on #relativeYearFraction(LocalDate).

Specified by:
zeroRatePointSensitivityWithSpread in interface DiscountFactors
Parameters:
yearFraction - the year fraction
sensitivityCurrency - the currency of the sensitivity
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodPerYear - the number of periods per year
Returns:
the point sensitivity of the zero rate
• parameterSensitivity

public CurrencyParameterSensitivities parameterSensitivity​(ZeroRateSensitivity pointSens)
Description copied from interface: DiscountFactors
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 interface DiscountFactors
Parameters:
pointSens - the point sensitivity to convert
Returns:
the parameter sensitivity
• createParameterSensitivity

public CurrencyParameterSensitivities createParameterSensitivity​(Currency currency,
DoubleArray sensitivities)
Description copied from interface: DiscountFactors
Creates the parameter sensitivity when the sensitivity values are known.

In most cases, DiscountFactors.parameterSensitivity(ZeroRateSensitivity) 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 discount factors are based on a single discount curve, then there will be one CurrencyParameterSensitivity in the result.

Specified by:
createParameterSensitivity in interface DiscountFactors
Parameters:
currency - the currency
sensitivities - the sensitivity values, which must match the parameter count
Returns:
the parameter sensitivity
• withCurve

public ZeroRatePeriodicDiscountFactors withCurve​(Curve curve)
Returns a new instance with a different curve.
Parameters:
curve - the new curve
Returns:
the new instance
• meta

public static ZeroRatePeriodicDiscountFactors.Meta meta()
The meta-bean for ZeroRatePeriodicDiscountFactors.
Returns:
the meta-bean, not null
• metaBean

public ZeroRatePeriodicDiscountFactors.Meta metaBean()
Specified by:
metaBean in interface org.joda.beans.Bean
• getCurrency

public Currency getCurrency()
Gets the currency that the discount factors are for.
Specified by:
getCurrency in interface DiscountFactors
Returns:
the value of the property, not null
• getValuationDate

public LocalDate getValuationDate()
Gets the valuation date.
Specified by:
getValuationDate in interface MarketDataView
Returns:
the value of the property, not null
• getCurve

public Curve getCurve()
Gets the underlying curve. The metadata of the curve must define a day count.
Returns:
the value of the property, not null
• equals

public boolean equals​(Object obj)
Overrides:
equals in class Object
• hashCode

public int hashCode()
Overrides:
hashCode in class Object
• toString

public String toString()
Overrides:
toString in class Object