Class BlackFxOptionFlatVolatilities
- java.lang.Object
-
- com.opengamma.strata.pricer.fxopt.BlackFxOptionFlatVolatilities
-
- All Implemented Interfaces:
MarketDataView
,ParameterizedData
,BlackFxOptionVolatilities
,FxOptionVolatilities
,Serializable
,org.joda.beans.Bean
,org.joda.beans.ImmutableBean
public final class BlackFxOptionFlatVolatilities extends Object implements BlackFxOptionVolatilities, org.joda.beans.ImmutableBean, Serializable
Volatility for FX options in the log-normal or Black model based on a curve.The volatility is represented by a curve on the expiry and the volatility is flat along the strike direction.
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
BlackFxOptionFlatVolatilities.Builder
The bean-builder forBlackFxOptionFlatVolatilities
.static class
BlackFxOptionFlatVolatilities.Meta
The meta-bean forBlackFxOptionFlatVolatilities
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BlackFxOptionFlatVolatilities.Builder
builder()
Returns a builder used to create an instance of the bean.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.ValueDerivatives
firstPartialDerivatives(CurrencyPair currencyPair, double expiry, double strike, double forward)
Computes the partial derivatives of the volatilities.CurrencyPair
getCurrencyPair()
Gets the currency pair that the volatilities are for.Curve
getCurve()
Gets the Black volatility curve.FxOptionVolatilitiesName
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.ZonedDateTime
getValuationDateTime()
Gets the valuation date-time.int
hashCode()
static BlackFxOptionFlatVolatilities.Meta
meta()
The meta-bean forBlackFxOptionFlatVolatilities
.BlackFxOptionFlatVolatilities.Meta
metaBean()
static BlackFxOptionFlatVolatilities
of(CurrencyPair currencyPair, ZonedDateTime valuationDateTime, Curve curve)
Obtains an instance from an expiry-volatility curve and the date-time for which it is valid.CurrencyParameterSensitivities
parameterSensitivity(PointSensitivities pointSensitivities)
Calculates the parameter sensitivity.double
price(double expiry, PutCall putCall, double strike, double forward, double volatility)
Calculates the price.double
relativeTime(ZonedDateTime dateTime)
Converts a time and date to a relative year fraction.BlackFxOptionFlatVolatilities.Builder
toBuilder()
Returns a builder that allows this bean to be mutated.String
toString()
double
volatility(CurrencyPair currencyPair, double expiry, double strike, double forward)
Calculates the volatility at the specified expiry.BlackFxOptionFlatVolatilities
withParameter(int parameterIndex, double newValue)
Returns a copy of the data with the value at the specified index altered.BlackFxOptionFlatVolatilities
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.fxopt.BlackFxOptionVolatilities
getVolatilityType
-
Methods inherited from interface com.opengamma.strata.pricer.fxopt.FxOptionVolatilities
getValuationDate, parameterSensitivity, volatility
-
-
-
-
Method Detail
-
of
public static BlackFxOptionFlatVolatilities of(CurrencyPair currencyPair, ZonedDateTime valuationDateTime, Curve curve)
Obtains an instance from an expiry-volatility curve and the date-time for which it is valid.The curve is specified by an instance of
Curve
, such asInterpolatedNodalCurve
. The curve must contain the correct metadata:- The x-value type must be
ValueType.YEAR_FRACTION
- The y-value type must be
ValueType.BLACK_VOLATILITY
- The day count must be set in the additional information using
CurveInfoType.DAY_COUNT
Curves.blackVolatilityByExpiry(String, DayCount)
.- Parameters:
currencyPair
- the currency pairvaluationDateTime
- the valuation date-timecurve
- the volatility curve- Returns:
- the volatilities
- The x-value type must be
-
getName
public FxOptionVolatilitiesName getName()
Description copied from interface:FxOptionVolatilities
Gets the name of these volatilities.- Specified by:
getName
in interfaceFxOptionVolatilities
- 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 BlackFxOptionFlatVolatilities 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 interfaceBlackFxOptionVolatilities
- Specified by:
withParameter
in interfaceFxOptionVolatilities
- 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 BlackFxOptionFlatVolatilities 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 interfaceBlackFxOptionVolatilities
- Specified by:
withPerturbation
in interfaceFxOptionVolatilities
- Specified by:
withPerturbation
in interfaceParameterizedData
- Parameters:
perturbation
- the perturbation to apply- Returns:
- a parameterized data instance based on this with the specified perturbation applied
-
volatility
public double volatility(CurrencyPair currencyPair, double expiry, double strike, double forward)
Description copied from interface:FxOptionVolatilities
Calculates the volatility at the specified expiry.This relies on expiry supplied by
FxOptionVolatilities.relativeTime(ZonedDateTime)
.- Specified by:
volatility
in interfaceFxOptionVolatilities
- Parameters:
currencyPair
- the currency pairexpiry
- the time to expiry as a year fractionstrike
- the option strike rateforward
- the forward rate- Returns:
- the volatility
-
parameterSensitivity
public CurrencyParameterSensitivities parameterSensitivity(PointSensitivities pointSensitivities)
Description copied from interface:FxOptionVolatilities
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 interfaceFxOptionVolatilities
- Parameters:
pointSensitivities
- the point sensitivities- Returns:
- the sensitivity to the underlying parameters
-
firstPartialDerivatives
public ValueDerivatives firstPartialDerivatives(CurrencyPair currencyPair, double expiry, double strike, double forward)
Description copied from interface:FxOptionVolatilities
Computes the partial derivatives of the volatilities.The first derivatives are
dVol/dExpiry and dVol/dStrike
. The derivatives are in the following order:- [0] derivative with respect to expiry
- [1] derivative with respect to strike
- Specified by:
firstPartialDerivatives
in interfaceFxOptionVolatilities
- Parameters:
currencyPair
- the currency pairexpiry
- the expiry at which the partial derivative is takenstrike
- the strike at which the partial derivative is takenforward
- the forward rate- Returns:
- the z-value and it's partial first derivatives
-
price
public double price(double expiry, PutCall putCall, double strike, double forward, double volatility)
Description copied from interface:FxOptionVolatilities
Calculates the price.This relies on expiry supplied by
FxOptionVolatilities.relativeTime(ZonedDateTime)
. This relies on volatility supplied byFxOptionVolatilities.volatility(CurrencyPair, double, double, double)
.- Specified by:
price
in interfaceFxOptionVolatilities
- Parameters:
expiry
- the time to expiry as a year fractionputCall
- whether the option is put or callstrike
- the option strike rateforward
- the forward ratevolatility
- the volatility- Returns:
- the price
-
relativeTime
public double relativeTime(ZonedDateTime dateTime)
Description copied from interface:FxOptionVolatilities
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 interfaceFxOptionVolatilities
- Parameters:
dateTime
- the date-time to find the relative year fraction of- Returns:
- the relative year fraction
-
meta
public static BlackFxOptionFlatVolatilities.Meta meta()
The meta-bean forBlackFxOptionFlatVolatilities
.- Returns:
- the meta-bean, not null
-
builder
public static BlackFxOptionFlatVolatilities.Builder builder()
Returns a builder used to create an instance of the bean.- Returns:
- the builder, not null
-
metaBean
public BlackFxOptionFlatVolatilities.Meta metaBean()
- Specified by:
metaBean
in interfaceorg.joda.beans.Bean
-
getCurrencyPair
public CurrencyPair getCurrencyPair()
Gets the currency pair that the volatilities are for.- Specified by:
getCurrencyPair
in interfaceFxOptionVolatilities
- Returns:
- the value of the property, not null
-
getValuationDateTime
public ZonedDateTime getValuationDateTime()
Gets the valuation date-time. All data items in this provider is calibrated for this date-time.- Specified by:
getValuationDateTime
in interfaceFxOptionVolatilities
- Returns:
- the value of the property, not null
-
getCurve
public Curve getCurve()
Gets the Black volatility curve.The x-values represent the expiry year-fraction. The metadata of the curve must define a day count.
- Returns:
- the value of the property, not null
-
toBuilder
public BlackFxOptionFlatVolatilities.Builder toBuilder()
Returns a builder that allows this bean to be mutated.- Returns:
- the mutable builder, not null
-
-