## Interface DiscountFactors

• All Superinterfaces:
MarketDataView, ParameterizedData
All Known Implementing Classes:
SimpleDiscountFactors, ZeroRateDiscountFactors, ZeroRatePeriodicDiscountFactors

public interface DiscountFactors
extends MarketDataView, ParameterizedData

The discount factor represents the time value of money for the specified currency when comparing the valuation date to the specified date.

• ### 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 yearFraction)
Gets the discount factor for specified year fraction.
default double discountFactor​(LocalDate date)
Gets the discount factor for the specified date.
double discountFactorTimeDerivative​(double yearFraction)
Returns the discount factor derivative with respect to the year fraction or time.
default double discountFactorWithSpread​(double yearFraction, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Gets the discount factor for the specified year fraction with z-spread.
default double discountFactorWithSpread​(LocalDate date, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Gets the discount factor for the specified date with z-spread.
Currency getCurrency()
Gets the currency.
static DiscountFactors of​(Currency currency, LocalDate valuationDate, Curve curve)
Obtains an instance from a curve.
CurrencyParameterSensitivities parameterSensitivity​(ZeroRateSensitivity pointSensitivity)
Calculates the parameter sensitivity from the point sensitivity.
double relativeYearFraction​(LocalDate date)
Calculates the relative time between the valuation date and the specified date.
DiscountFactors withParameter​(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.
DiscountFactors withPerturbation​(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.
double zeroRate​(double yearFraction)
Gets the continuously compounded zero rate for specified year fraction.
default double zeroRate​(LocalDate date)
Gets the continuously compounded zero rate for the specified date.
default ZeroRateSensitivity zeroRatePointSensitivity​(double yearFraction)
Calculates the zero rate point sensitivity at the 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.
default ZeroRateSensitivity zeroRatePointSensitivity​(LocalDate date)
Calculates the zero rate point sensitivity at the specified date.
default ZeroRateSensitivity zeroRatePointSensitivity​(LocalDate date, Currency sensitivityCurrency)
Calculates the zero rate point sensitivity at the specified date specifying the currency of the sensitivity.
default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified year fraction.
default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction, Currency sensitivityCurrency, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified year fraction specifying the currency of the sensitivity.
default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(LocalDate date, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified date.
default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(LocalDate date, Currency sensitivityCurrency, double zSpread, CompoundedRateType compoundedRateType, int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified date specifying the currency of the sensitivity.
• ### Methods inherited from interface com.opengamma.strata.market.MarketDataView

findData, getValuationDate
• ### Methods inherited from interface com.opengamma.strata.market.param.ParameterizedData

findParameterIndex, getParameter, getParameterCount, getParameterMetadata
• ### Method Detail

• #### of

static DiscountFactors of​(Currency currency,
LocalDate valuationDate,
Curve curve)
Obtains an instance from a curve.

The curve is specified by an instance of Curve, such as InterpolatedNodalCurve. The curve must have x-values of year fractions with the day count specified. The y-values must be zero rates or discount factors.

Parameters:
currency - the currency
valuationDate - the valuation date for which the curve is valid
curve - the underlying curve
Returns:
the discount factors view
• #### getCurrency

Currency getCurrency()
Gets the currency.

The currency that discount factors are provided for.

Returns:
the currency
• #### withParameter

DiscountFactors 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 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

DiscountFactors 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 ParameterizedData
Parameters:
perturbation - the perturbation to apply
Returns:
a parameterized data instance based on this with the specified perturbation applied
• #### relativeYearFraction

double relativeYearFraction​(LocalDate date)
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.

Parameters:
date - the date
Returns:
the year fraction
Throws:
RuntimeException - if it is not possible to convert dates to relative times
• #### discountFactor

default double discountFactor​(LocalDate date)
Gets the discount factor for the specified date.

The discount factor represents the time value of money for the specified currency when comparing the valuation date to the specified date.

If the valuation date is on or after the specified date, the discount factor is 1.

Parameters:
date - the date to discount to
Returns:
the discount factor
Throws:
RuntimeException - if the value cannot be obtained
• #### discountFactor

double discountFactor​(double yearFraction)
Gets the discount factor for specified year fraction.

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

Parameters:
yearFraction - the year fraction
Returns:
the discount factor
Throws:
RuntimeException - if the value cannot be obtained
• #### discountFactorTimeDerivative

double discountFactorTimeDerivative​(double yearFraction)
Returns the discount factor derivative with respect to the year fraction or time.

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

Parameters:
yearFraction - the year fraction
Returns:
the discount factor derivative
Throws:
RuntimeException - if the value cannot be obtained

default double discountFactorWithSpread​(LocalDate date,
CompoundedRateType compoundedRateType,
int periodsPerYear)
Gets the discount factor for the specified date with z-spread.

The discount factor represents the time value of money for the specified currency when comparing the valuation date to the specified date.

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

If the valuation date is on or after the specified date, the discount factor is 1.

Parameters:
date - the date to discount to
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the discount factor
Throws:
RuntimeException - if the value cannot be obtained

default double discountFactorWithSpread​(double yearFraction,
CompoundedRateType compoundedRateType,
int periodsPerYear)
Gets the discount factor for the specified year fraction with z-spread.

The discount factor represents the time value of money for the specified currency when comparing the valuation date to the specified date.

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

If the valuation date is on or after the specified date, the discount factor is 1.

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

Parameters:
yearFraction - the year fraction
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the discount factor
Throws:
RuntimeException - if the value cannot be obtained
• #### zeroRate

default double zeroRate​(LocalDate date)
Gets the continuously compounded zero rate for the specified date.

The continuously compounded zero rate is coherent to discountFactor(LocalDate) along with year fraction which is computed internally in each implementation.

Parameters:
date - the date to discount to
Returns:
the zero rate
Throws:
RuntimeException - if the value cannot be obtained
• #### zeroRate

double zeroRate​(double yearFraction)
Gets the continuously compounded zero rate for specified year fraction.

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

Parameters:
yearFraction - the year fraction
Returns:
the zero rate
Throws:
RuntimeException - if the value cannot be obtained
• #### zeroRatePointSensitivity

default ZeroRateSensitivity zeroRatePointSensitivity​(LocalDate date)
Calculates the zero rate point sensitivity at the specified date.

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 discountFactor(LocalDate).

Parameters:
date - the date to discount to
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated
• #### zeroRatePointSensitivity

default ZeroRateSensitivity zeroRatePointSensitivity​(double yearFraction)
Calculates the zero rate point sensitivity at the specified year fraction.

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 discountFactor(LocalDate).

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

Parameters:
yearFraction - the year fraction
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated
• #### zeroRatePointSensitivity

default ZeroRateSensitivity zeroRatePointSensitivity​(LocalDate date,
Currency sensitivityCurrency)
Calculates the zero rate point sensitivity at the specified date 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 discountFactor(LocalDate).

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

Parameters:
date - the date to discount to
sensitivityCurrency - the currency of the sensitivity
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated
• #### zeroRatePointSensitivity

ZeroRateSensitivity zeroRatePointSensitivity​(double yearFraction,
Currency sensitivityCurrency)
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 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).

Parameters:
yearFraction - the year fraction
sensitivityCurrency - the currency of the sensitivity
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated

default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(LocalDate date,
CompoundedRateType compoundedRateType,
int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified date.

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 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.

Parameters:
date - the date to discount to
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated

default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction,
CompoundedRateType compoundedRateType,
int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified year fraction.

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 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.

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

Parameters:
yearFraction - the year fraction
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated

default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(LocalDate date,
Currency sensitivityCurrency,
CompoundedRateType compoundedRateType,
int periodsPerYear)
Calculates the zero rate point sensitivity with z-spread at the specified date 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 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.

Parameters:
date - the date to discount to
sensitivityCurrency - the currency of the sensitivity
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated

default ZeroRateSensitivity zeroRatePointSensitivityWithSpread​(double yearFraction,
Currency sensitivityCurrency,
CompoundedRateType compoundedRateType,
int periodsPerYear)
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 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).

Parameters:
yearFraction - the year fraction
sensitivityCurrency - the currency of the sensitivity
zSpread - the z-spread
compoundedRateType - the compounded rate type
periodsPerYear - the number of periods per year
Returns:
the point sensitivity of the zero rate
Throws:
RuntimeException - if the result cannot be calculated
• #### parameterSensitivity

CurrencyParameterSensitivities parameterSensitivity​(ZeroRateSensitivity pointSensitivity)
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.

Parameters:
pointSensitivity - the point sensitivity to convert
Returns:
the parameter sensitivity
Throws:
RuntimeException - if the result cannot be calculated
• #### createParameterSensitivity

CurrencyParameterSensitivities createParameterSensitivity​(Currency currency,
DoubleArray sensitivities)
Creates the parameter sensitivity when the sensitivity values are known.

In most cases, 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.

Parameters:
currency - the currency
sensitivities - the sensitivity values, which must match the parameter count
Returns:
the parameter sensitivity
Throws:
RuntimeException - if the result cannot be calculated