Class BlackSwaptionExpiryTenorVolatilities
- java.lang.Object
-
- com.opengamma.strata.pricer.swaption.BlackSwaptionExpiryTenorVolatilities
-
- All Implemented Interfaces:
MarketDataView
,ParameterizedData
,BlackSwaptionVolatilities
,SwaptionVolatilities
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class BlackSwaptionExpiryTenorVolatilities extends Object implements BlackSwaptionVolatilities, org.joda.beans.ImmutableBean, Serializable
Volatility for swaptions in the log-normal or Black model.The volatility is represented by a surface on the expiry and swap tenor dimensions.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BlackSwaptionExpiryTenorVolatilities.Meta
The meta-bean forBlackSwaptionExpiryTenorVolatilities
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.FixedFloatSwapConvention
getConvention()
Gets the swap convention that the volatilities are to be used for.SwaptionVolatilitiesName
getName()
Gets the name of these volatilities.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.Surface
getSurface()
Gets the Black volatility surface.ZonedDateTime
getValuationDateTime()
Gets the valuation date-time.int
hashCode()
static BlackSwaptionExpiryTenorVolatilities.Meta
meta()
The meta-bean forBlackSwaptionExpiryTenorVolatilities
.BlackSwaptionExpiryTenorVolatilities.Meta
metaBean()
static BlackSwaptionExpiryTenorVolatilities
of(FixedFloatSwapConvention convention, ZonedDateTime valuationDateTime, Surface surface)
Obtains an instance from the implied volatility surface and the date-time for which it is valid.CurrencyParameterSensitivities
parameterSensitivity(PointSensitivities pointSensitivities)
Calculates the parameter sensitivity.double
price(double expiry, double tenor, PutCall putCall, double strike, double forwardRate, double volatility)
Calculates the price.double
priceDelta(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Calculates the price delta.double
priceGamma(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Calculates the price gamma.double
priceTheta(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Calculates the price theta.double
priceVega(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Calculates the price vega.double
relativeTime(ZonedDateTime dateTime)
Converts a time and date to a relative year fraction.double
tenor(LocalDate startDate, LocalDate endDate)
Calculates the tenor of the swap based on its start date and end date.String
toString()
double
volatility(double expiry, double tenor, double strike, double forwardRate)
Calculates the volatility at the specified expiry.BlackSwaptionExpiryTenorVolatilities
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.BlackSwaptionExpiryTenorVolatilities
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.pricer.swaption.BlackSwaptionVolatilities
getVolatilityType
-
Methods inherited from interface com.opengamma.strata.pricer.swaption.SwaptionVolatilities
getValuationDate, parameterSensitivity, volatility
-
-
-
-
Method Detail
-
of
public static BlackSwaptionExpiryTenorVolatilities of(FixedFloatSwapConvention convention, ZonedDateTime valuationDateTime, Surface surface)
Obtains an instance from the implied volatility surface and the date-time for which it is valid.The surface is specified by an instance of
Surface
, such asInterpolatedNodalSurface
. The surface 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.BLACK_VOLATILITY
- The day count must be set in the additional information using
SurfaceInfoType.DAY_COUNT
Surfaces.blackVolatilityByExpiryTenor(String, DayCount)
.- Parameters:
convention
- the swap convention that the volatilities are to be used forvaluationDateTime
- the valuation date-timesurface
- the implied volatility surface- Returns:
- the volatilities
- The x-value type must be
-
getName
public SwaptionVolatilitiesName getName()
Description copied from interface:SwaptionVolatilities
Gets the name of these volatilities.- Specified by:
getName
in interfaceSwaptionVolatilities
- Returns:
- the name
-
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
-
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 BlackSwaptionExpiryTenorVolatilities 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 interfaceBlackSwaptionVolatilities
- Specified by:
withParameter
in interfaceParameterizedData
- Specified by:
withParameter
in interfaceSwaptionVolatilities
- 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 BlackSwaptionExpiryTenorVolatilities 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 interfaceBlackSwaptionVolatilities
- Specified by:
withPerturbation
in interfaceParameterizedData
- Specified by:
withPerturbation
in interfaceSwaptionVolatilities
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
volatility
public double volatility(double expiry, double tenor, double strike, double forwardRate)
Description copied from interface:SwaptionVolatilities
Calculates the volatility at the specified expiry.This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
.- Specified by:
volatility
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionstrike
- the option strike rateforwardRate
- the forward rate of the underlying swap- Returns:
- the volatility
-
parameterSensitivity
public CurrencyParameterSensitivities parameterSensitivity(PointSensitivities pointSensitivities)
Description copied from interface:SwaptionVolatilities
Calculates the parameter sensitivity.This computes the
CurrencyParameterSensitivities
associated with thePointSensitivities
. This corresponds to the projection of the point sensitivity to the internal parameters representation.- Specified by:
parameterSensitivity
in interfaceSwaptionVolatilities
- Parameters:
pointSensitivities
- the point sensitivities- Returns:
- the sensitivity to the underlying parameters
-
price
public double price(double expiry, double tenor, PutCall putCall, double strike, double forwardRate, double volatility)
Description copied from interface:SwaptionVolatilities
Calculates the price.This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
. This relies on volatility supplied bySwaptionVolatilities.volatility(double, double, double, double)
.- Specified by:
price
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforwardRate
- the forward rate of the underlying swapvolatility
- the volatility- Returns:
- the price
-
priceDelta
public double priceDelta(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Description copied from interface:SwaptionVolatilities
Calculates the price delta.This is the forward driftless delta.
This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
. This relies on volatility supplied bySwaptionVolatilities.volatility(double, double, double, double)
.- Specified by:
priceDelta
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforward
- the forward rate of the underlying swapvolatility
- the volatility- Returns:
- the delta
-
priceGamma
public double priceGamma(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Description copied from interface:SwaptionVolatilities
Calculates the price gamma.This is the second order sensitivity of the forward option value to the forward.
This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
. This relies on volatility supplied bySwaptionVolatilities.volatility(double, double, double, double)
.- Specified by:
priceGamma
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforward
- the forward rate of the underlying swapvolatility
- the volatility- Returns:
- the gamma
-
priceTheta
public double priceTheta(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Description copied from interface:SwaptionVolatilities
Calculates the price theta.This is the driftless sensitivity of the present value to a change in time to maturity.
This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
. This relies on volatility supplied bySwaptionVolatilities.volatility(double, double, double, double)
.- Specified by:
priceTheta
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforward
- the forward rate of the underlying swapvolatility
- the volatility- Returns:
- the theta
-
priceVega
public double priceVega(double expiry, double tenor, PutCall putCall, double strike, double forward, double volatility)
Description copied from interface:SwaptionVolatilities
Calculates the price vega.This is the sensitivity of the option forward price to the implied volatility.
This relies on expiry supplied by
SwaptionVolatilities.relativeTime(ZonedDateTime)
. This relies on tenor supplied bySwaptionVolatilities.tenor(LocalDate, LocalDate)
. This relies on volatility supplied bySwaptionVolatilities.volatility(double, double, double, double)
.- Specified by:
priceVega
in interfaceSwaptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractiontenor
- the tenor of the instrument as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforward
- the forward rate of the underlying swapvolatility
- the volatility- Returns:
- the vega
-
relativeTime
public double relativeTime(ZonedDateTime dateTime)
Description copied from interface:SwaptionVolatilities
Converts a time and date to a relative year fraction.When the date is after the valuation date (and potentially time), the returned number is negative.
- Specified by:
relativeTime
in interfaceSwaptionVolatilities
- Parameters:
dateTime
- the date-time to find the relative year fraction of- Returns:
- the relative year fraction
-
tenor
public double tenor(LocalDate startDate, LocalDate endDate)
Description copied from interface:SwaptionVolatilities
Calculates the tenor of the swap based on its start date and end date.- Specified by:
tenor
in interfaceSwaptionVolatilities
- Parameters:
startDate
- the start dateendDate
- the end date- Returns:
- the tenor
-
meta
public static BlackSwaptionExpiryTenorVolatilities.Meta meta()
The meta-bean forBlackSwaptionExpiryTenorVolatilities
.- Returns:
- the meta-bean, not null
-
metaBean
public BlackSwaptionExpiryTenorVolatilities.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getConvention
public FixedFloatSwapConvention getConvention()
Gets the swap convention that the volatilities are to be used for.- Specified by:
getConvention
in interfaceSwaptionVolatilities
- Returns:
- the value of the property, not null
-
getValuationDateTime
public ZonedDateTime getValuationDateTime()
Gets the valuation date-time.The volatilities are calibrated for this date-time.
- Specified by:
getValuationDateTime
in interfaceSwaptionVolatilities
- Returns:
- the value of the property, not null
-
getSurface
public Surface getSurface()
Gets the Black volatility surface.The x-value of the surface is the expiry, as a year fraction. The y-value of the surface is the swap tenor, as a year fraction rounded to the month.
- Returns:
- the value of the property, not null
-
-