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
Curvedefined by expiry.The implementation allows for shifted SABR model. The shift parameter is also
Curvedefined by expiry.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublealpha(double expiry)Calculates the alpha parameter for time to expiry.doublebeta(double expiry)Calculates the beta parameter for time to expiry.booleanequals(Object obj)CurvegetAlphaCurve()Gets the alpha (volatility level) curve.CurvegetBetaCurve()Gets the beta (elasticity) curve.DayCountgetDayCount()Gets the day count used to calculate the expiry year fraction.CurvegetNuCurve()Gets the nu (volatility of volatility) curve.doublegetParameter(int parameterIndex)Gets the value of the parameter at the specified index.intgetParameterCount()Gets the number of parameters.ParameterMetadatagetParameterMetadata(int parameterIndex)Gets the metadata of the parameter at the specified index.CurvegetRhoCurve()Gets the rho (correlation) curve.SabrVolatilityFormulagetSabrVolatilityFormula()Gets the SABR volatility formula.CurvegetShiftCurve()Gets the shift parameter of shifted SABR model.inthashCode()static org.joda.beans.TypedMetaBean<SabrParameters>meta()The meta-bean forSabrParameters.org.joda.beans.TypedMetaBean<SabrParameters>metaBean()doublenu(double expiry)Calculates the nu parameter for time to expiry.static SabrParametersof(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 SabrParametersof(Curve alphaCurve, Curve betaCurve, Curve rhoCurve, Curve nuCurve, SabrVolatilityFormula sabrFormula)Obtains an instance without shift from nodal curves and volatility function provider.doublerho(double expiry)Calculates the rho parameter for time to expiry.doubleshift(double expiry)Calculates the shift parameter for time to expiry.StringtoString()doublevolatility(double expiry, double strike, double forward)Calculates the volatility for given expiry, strike and forward rate.ValueDerivativesvolatilityAdjoint(double expiry, double strike, double forward)Calculates the volatility and associated sensitivities.SabrParameterswithParameter(int parameterIndex, double newValue)Returns a copy of the data with the value at the specified index altered.SabrParameterswithPerturbation(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_RHOorValueType.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_RHOorValueType.SABR_NUas 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:ParameterizedDataGets 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:
getParameterCountin interfaceParameterizedData- Returns:
- the number of parameters
-
getParameter
public double getParameter(int parameterIndex)
Description copied from interface:ParameterizedDataGets the value of the parameter at the specified index.- Specified by:
getParameterin 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:ParameterizedDataGets the metadata of the parameter at the specified index.If there is no specific parameter metadata, an empty instance will be returned.
- Specified by:
getParameterMetadatain 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:ParameterizedDataReturns 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:
withParameterin 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:ParameterizedDataReturns 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:
withPerturbationin 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:
metaBeanin 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
-
-