Class IsdaCreditDiscountFactors
- java.lang.Object
-
- com.opengamma.strata.pricer.credit.IsdaCreditDiscountFactors
-
- All Implemented Interfaces:
MarketDataView
,ParameterizedData
,CreditDiscountFactors
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class IsdaCreditDiscountFactors extends Object implements CreditDiscountFactors, org.joda.beans.ImmutableBean, Serializable
ISDA compliant zero rate discount factors.This is used to price credit default swaps under ISDA standard model.
The underlying curve must be zero rate curve represented by
InterpolatedNodalCurve
for multiple data points andInterpolatedNodalCurve
for a single data point. The zero rates must be interpolated byProductLinearCurveInterpolator
and extrapolated byFlatCurveExtrapolator
on the left andProductLinearCurveExtrapolator
on the right.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IsdaCreditDiscountFactors.Meta
The meta-bean forIsdaCreditDiscountFactors
.
-
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.double
discountFactor(double yearFraction)
Gets the discount factor for specified year fraction.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.NodalCurve
getCurve()
Gets the underlying curve.DayCount
getDayCount()
Obtains day count convention.double
getParameter(int parameterIndex)
Gets the value of the parameter at the specified index.int
getParameterCount()
Gets the number of parameters.DoubleArray
getParameterKeys()
Obtains the parameter keys of the underlying curve.ParameterMetadata
getParameterMetadata(int parameterIndex)
Gets the metadata of the parameter at the specified index.LocalDate
getValuationDate()
Gets the valuation date.int
hashCode()
boolean
isIsdaCompliant()
Checks if the instance is based on an ISDA compliant curve.static IsdaCreditDiscountFactors.Meta
meta()
The meta-bean forIsdaCreditDiscountFactors
.IsdaCreditDiscountFactors.Meta
metaBean()
static IsdaCreditDiscountFactors
of(Currency currency, LocalDate valuationDate, CurveName curveName, DoubleArray yearFractions, DoubleArray zeroRates, DayCount dayCount)
Creates an instance from year fraction and zero rate values.static IsdaCreditDiscountFactors
of(Currency currency, LocalDate valuationDate, NodalCurve curve)
Creates an instance from the underlying 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
toDiscountFactors()
Creates an instance ofDiscountFactors
.String
toString()
IsdaCreditDiscountFactors
withCurve(NodalCurve curve)
Returns a new instance with a different curve.IsdaCreditDiscountFactors
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.IsdaCreditDiscountFactors
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.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.pricer.credit.CreditDiscountFactors
discountFactor, zeroRate, zeroRatePointSensitivity, zeroRatePointSensitivity, zeroRatePointSensitivity
-
-
-
-
Method Detail
-
of
public static IsdaCreditDiscountFactors of(Currency currency, LocalDate valuationDate, NodalCurve curve)
Creates an instance from the underlying curve.- Parameters:
currency
- the currencyvaluationDate
- the valuation datecurve
- the underlying curve- Returns:
- the instance
-
of
public static IsdaCreditDiscountFactors of(Currency currency, LocalDate valuationDate, CurveName curveName, DoubleArray yearFractions, DoubleArray zeroRates, DayCount dayCount)
Creates an instance from year fraction and zero rate values.- Parameters:
currency
- the currencyvaluationDate
- the valuation datecurveName
- the curve nameyearFractions
- the year fractionszeroRates
- the zero ratesdayCount
- the day count- Returns:
- the instance
-
isIsdaCompliant
public boolean isIsdaCompliant()
Description copied from interface:CreditDiscountFactors
Checks if the instance is based on an ISDA compliant curve.This returns 'false' by default, and should be overridden when needed.
- Specified by:
isIsdaCompliant
in interfaceCreditDiscountFactors
- Returns:
- true if this is an ISDA compliant curve, false otherwise
-
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
-
getParameterKeys
public DoubleArray getParameterKeys()
Description copied from interface:CreditDiscountFactors
Obtains the parameter keys of the underlying curve.- Specified by:
getParameterKeys
in interfaceCreditDiscountFactors
- Returns:
- the parameter keys
-
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 IsdaCreditDiscountFactors 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 interfaceCreditDiscountFactors
- Specified by:
withParameter
in 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 IsdaCreditDiscountFactors 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 interfaceCreditDiscountFactors
- Specified by:
withPerturbation
in interfaceParameterizedData
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
getDayCount
public DayCount getDayCount()
Description copied from interface:CreditDiscountFactors
Obtains day count convention.This is typically the day count convention of the underlying curve.
- Specified by:
getDayCount
in interfaceCreditDiscountFactors
- Returns:
- the day count
-
relativeYearFraction
public double relativeYearFraction(LocalDate date)
Description copied from interface:CreditDiscountFactors
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 aDayCount
.- Specified by:
relativeYearFraction
in interfaceCreditDiscountFactors
- Parameters:
date
- the date- Returns:
- the year fraction
-
discountFactor
public double discountFactor(double yearFraction)
Description copied from interface:CreditDiscountFactors
Gets the discount factor for specified year fraction.The year fraction must be based on
#relativeYearFraction(LocalDate)
.- Specified by:
discountFactor
in interfaceCreditDiscountFactors
- Parameters:
yearFraction
- the year fraction- Returns:
- the discount factor
-
zeroRate
public double zeroRate(double yearFraction)
Description copied from interface:CreditDiscountFactors
Gets the continuously compounded zero rate for specified year fraction.The year fraction must be based on
#relativeYearFraction(LocalDate)
.- Specified by:
zeroRate
in interfaceCreditDiscountFactors
- Parameters:
yearFraction
- the year fraction- Returns:
- the zero rate
-
zeroRatePointSensitivity
public ZeroRateSensitivity zeroRatePointSensitivity(double yearFraction, Currency sensitivityCurrency)
Description copied from interface:CreditDiscountFactors
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 ofCreditDiscountFactors.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 interfaceCreditDiscountFactors
- Parameters:
yearFraction
- the year fractionsensitivityCurrency
- the currency of the sensitivity- Returns:
- the point sensitivity of the zero rate
-
parameterSensitivity
public CurrencyParameterSensitivities parameterSensitivity(ZeroRateSensitivity pointSensitivity)
Description copied from interface:CreditDiscountFactors
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 interfaceCreditDiscountFactors
- Parameters:
pointSensitivity
- the point sensitivity to convert- Returns:
- the parameter sensitivity
-
createParameterSensitivity
public CurrencyParameterSensitivities createParameterSensitivity(Currency currency, DoubleArray sensitivities)
Description copied from interface:CreditDiscountFactors
Creates the parameter sensitivity when the sensitivity values are known.In most cases,
CreditDiscountFactors.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 oneCurrencyParameterSensitivity
in the result.- Specified by:
createParameterSensitivity
in interfaceCreditDiscountFactors
- Parameters:
currency
- the currencysensitivities
- the sensitivity values, which must match the parameter count- Returns:
- the parameter sensitivity
-
toDiscountFactors
public DiscountFactors toDiscountFactors()
Description copied from interface:CreditDiscountFactors
Creates an instance ofDiscountFactors
.- Specified by:
toDiscountFactors
in interfaceCreditDiscountFactors
- Returns:
- the instance
-
withCurve
public IsdaCreditDiscountFactors withCurve(NodalCurve curve)
Returns a new instance with a different curve.- Parameters:
curve
- the new curve- Returns:
- the new instance
-
meta
public static IsdaCreditDiscountFactors.Meta meta()
The meta-bean forIsdaCreditDiscountFactors
.- Returns:
- the meta-bean, not null
-
metaBean
public IsdaCreditDiscountFactors.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getCurrency
public Currency getCurrency()
Gets the currency that the discount factors are for.- Specified by:
getCurrency
in interfaceCreditDiscountFactors
- 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 NodalCurve getCurve()
Gets the underlying curve.The metadata of the curve must define a day count.
- Returns:
- the value of the property, not null
-
-