Class SabrParameters
- java.lang.Object
-
- com.opengamma.strata.pricer.model.SabrParameters
-
- All Implemented Interfaces:
ParameterizedData
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class SabrParameters extends Object implements ParameterizedData, org.joda.beans.ImmutableBean, Serializable
The volatility surface description under SABR model.This is used in interest rate modeling. Each SABR parameter is a
Curve
defined by expiry.The implementation allows for shifted SABR model. The shift parameter is also
Curve
defined by expiry.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
alpha(double expiry)
Calculates the alpha parameter for time to expiry.double
beta(double expiry)
Calculates the beta parameter for time to expiry.boolean
equals(Object obj)
Curve
getAlphaCurve()
Gets the alpha (volatility level) curve.Curve
getBetaCurve()
Gets the beta (elasticity) curve.DayCount
getDayCount()
Gets the day count used to calculate the expiry year fraction.Curve
getNuCurve()
Gets the nu (volatility of volatility) 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.Curve
getRhoCurve()
Gets the rho (correlation) curve.SabrVolatilityFormula
getSabrVolatilityFormula()
Gets the SABR volatility formula.Curve
getShiftCurve()
Gets the shift parameter of shifted SABR model.int
hashCode()
static org.joda.beans.TypedMetaBean<SabrParameters>
meta()
The meta-bean forSabrParameters
.org.joda.beans.TypedMetaBean<SabrParameters>
metaBean()
double
nu(double expiry)
Calculates the nu parameter for time to expiry.static SabrParameters
of(Curve alphaCurve, Curve betaCurve, Curve rhoCurve, Curve nuCurve, Curve shiftCurve, SabrVolatilityFormula sabrFormula)
Obtains an instance with shift from nodal curves and volatility function provider.static SabrParameters
of(Curve alphaCurve, Curve betaCurve, Curve rhoCurve, Curve nuCurve, SabrVolatilityFormula sabrFormula)
Obtains an instance without shift from nodal curves and volatility function provider.double
rho(double expiry)
Calculates the rho parameter for time to expiry.double
shift(double expiry)
Calculates the shift parameter for time to expiry.String
toString()
double
volatility(double expiry, double strike, double forward)
Calculates the volatility for given expiry, strike and forward rate.ValueDerivatives
volatilityAdjoint(double expiry, double strike, double forward)
Calculates the volatility and associated sensitivities.SabrParameters
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.SabrParameters
withPerturbation(ParameterPerturbation perturbation)
Returns a perturbed copy of the data.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.opengamma.strata.market.param.ParameterizedData
findParameterIndex
-
-
-
-
Method Detail
-
of
public static SabrParameters of(Curve alphaCurve, Curve betaCurve, Curve rhoCurve, Curve nuCurve, SabrVolatilityFormula sabrFormula)
Obtains an instance without shift from nodal curves and volatility function provider.Each curve is specified by an instance of
Curve
, such asInterpolatedNodalCurve
. The curves must contain the correct metadata:- The x-value type must be
ValueType.YEAR_FRACTION
- The y-value type must be
ValueType.SABR_ALPHA
,ValueType.SABR_BETA
,ValueType.SABR_RHO
orValueType.SABR_NU
- The day count must be set in the additional information of the Alpha curve using
CurveInfoType.DAY_COUNT
, if present on other curves it must match that on the Alpha
Curves.sabrParameterByExpiry(String, DayCount, ValueType)
.- Parameters:
alphaCurve
- the alpha curvebetaCurve
- the beta curverhoCurve
- the rho curvenuCurve
- the nu curvesabrFormula
- the SABR formula- Returns:
SabrParameters
- The x-value type must be
-
of
public static SabrParameters of(Curve alphaCurve, Curve betaCurve, Curve rhoCurve, Curve nuCurve, Curve shiftCurve, SabrVolatilityFormula sabrFormula)
Obtains an instance with shift from nodal curves and volatility function provider.Each curve is specified by an instance of
Curve
, such asInterpolatedNodalCurve
. The curves must contain the correct metadata:- The x-value type must be
ValueType.YEAR_FRACTION
- The y-value type must be
ValueType.YEAR_FRACTION
- The z-value type must be
ValueType.SABR_ALPHA
,ValueType.SABR_BETA
,ValueType.SABR_RHO
orValueType.SABR_NU
as appropriate - The day count must be set in the additional information of the alpha curve using
CurveInfoType.DAY_COUNT
, if present on other curves it must match that on the alpha
Suitable curve metadata can be created using
Curves.sabrParameterByExpiry(String, DayCount, ValueType)
.- Parameters:
alphaCurve
- the alpha curvebetaCurve
- the beta curverhoCurve
- the rho curvenuCurve
- the nu curveshiftCurve
- the shift curvesabrFormula
- the SABR formula- Returns:
SabrParameters
- The x-value type must be
-
getDayCount
public DayCount getDayCount()
Gets the day count used to calculate the expiry year fraction.- Returns:
- the day count
-
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
-
withParameter
public SabrParameters 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
- 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 SabrParameters 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
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
alpha
public double alpha(double expiry)
Calculates the alpha parameter for time to expiry.- Parameters:
expiry
- the time to expiry as a year fraction- Returns:
- the alpha parameter
-
beta
public double beta(double expiry)
Calculates the beta parameter for time to expiry.- Parameters:
expiry
- the time to expiry as a year fraction- Returns:
- the beta parameter
-
rho
public double rho(double expiry)
Calculates the rho parameter for time to expiry.- Parameters:
expiry
- the time to expiry as a year fraction- Returns:
- the rho parameter
-
nu
public double nu(double expiry)
Calculates the nu parameter for time to expiry.- Parameters:
expiry
- the time to expiry as a year fraction- Returns:
- the nu parameter
-
shift
public double shift(double expiry)
Calculates the shift parameter for time to expiry.- Parameters:
expiry
- the time to expiry as a year fraction- Returns:
- the shift parameter
-
volatility
public double volatility(double expiry, double strike, double forward)
Calculates the volatility for given expiry, strike and forward rate.- Parameters:
expiry
- the time to expiry as a year fractionstrike
- the strikeforward
- the forward- Returns:
- the volatility
-
volatilityAdjoint
public ValueDerivatives volatilityAdjoint(double expiry, double strike, double forward)
Calculates the volatility and associated sensitivities.The derivatives are stored in an array with:
- [0] derivative with respect to the forward
- [1] derivative with respect to the forward strike
- [2] derivative with respect to the alpha
- [3] derivative with respect to the beta
- [4] derivative with respect to the rho
- [5] derivative with respect to the nu
- Parameters:
expiry
- the time to expiry as a year fractionstrike
- the strikeforward
- the forward- Returns:
- the volatility and associated derivatives
-
meta
public static org.joda.beans.TypedMetaBean<SabrParameters> meta()
The meta-bean forSabrParameters
.- Returns:
- the meta-bean, not null
-
metaBean
public org.joda.beans.TypedMetaBean<SabrParameters> metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getAlphaCurve
public Curve getAlphaCurve()
Gets the alpha (volatility level) curve.The x value of the curve is the expiry.
- Returns:
- the value of the property, not null
-
getBetaCurve
public Curve getBetaCurve()
Gets the beta (elasticity) curve.The x value of the curve is the expiry.
- Returns:
- the value of the property, not null
-
getRhoCurve
public Curve getRhoCurve()
Gets the rho (correlation) curve.The x value of the curve is the expiry.
- Returns:
- the value of the property, not null
-
getNuCurve
public Curve getNuCurve()
Gets the nu (volatility of volatility) curve.The x value of the curve is the expiry.
- Returns:
- the value of the property, not null
-
getShiftCurve
public Curve getShiftCurve()
Gets the shift parameter of shifted SABR model.The x value of the curve is the expiry. The shift is set to be 0 unless specified.
- Returns:
- the value of the property, not null
-
getSabrVolatilityFormula
public SabrVolatilityFormula getSabrVolatilityFormula()
Gets the SABR volatility formula.- Returns:
- the value of the property, not null
-
-