Class VolatilityFunctionProvider<T extends SmileModelData>
- java.lang.Object
-
- com.opengamma.strata.pricer.impl.volatility.smile.VolatilityFunctionProvider<T>
-
- Type Parameters:
T
- Type of the data needed for the volatility function
- Direct Known Subclasses:
SabrHaganVolatilityFunctionProvider
,SsviVolatilityFunction
public abstract class VolatilityFunctionProvider<T extends SmileModelData> extends Object
Provides functions that return volatility and its sensitivity to volatility model parameters.
-
-
Constructor Summary
Constructors Constructor Description VolatilityFunctionProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract double
volatility(double forward, double strike, double timeToExpiry, T data)
Calculates the volatility.ValueDerivatives
volatilityAdjoint(double forward, double strike, double timeToExpiry, T data)
Calculates volatility and the adjoint (volatility sensitivity to forward, strike and model parameters).abstract double
volatilityAdjoint2(double forward, double strike, double timeToExpiry, T data, double[] volatilityD, double[][] volatilityD2)
Computes the first and second order derivatives of the volatility.
-
-
-
Method Detail
-
volatility
public abstract double volatility(double forward, double strike, double timeToExpiry, T data)
Calculates the volatility.- Parameters:
forward
- the forward value of the underlyingstrike
- the strike value of the optiontimeToExpiry
- the time to expiry of the optiondata
- the model data- Returns:
- the volatility
-
volatilityAdjoint
public ValueDerivatives volatilityAdjoint(double forward, double strike, double timeToExpiry, T data)
Calculates volatility and the adjoint (volatility sensitivity to forward, strike and model parameters).By default the derivatives are computed by central finite difference approximation. This should be overridden in each subclass.
- Parameters:
forward
- the forward value of the underlyingstrike
- the strike value of the optiontimeToExpiry
- the time to expiry of the optiondata
- the model data- Returns:
- the volatility and associated derivatives
-
volatilityAdjoint2
public abstract double volatilityAdjoint2(double forward, double strike, double timeToExpiry, T data, double[] volatilityD, double[][] volatilityD2)
Computes the first and second order derivatives of the volatility.The first derivative values will be stored in the input array
volatilityD
The array contains, [0] Derivative w.r.t the forward, [1] the derivative w.r.t the strike, then followed by model parameters. Thus the length of the array should be 2 + (number of model parameters).The second derivative values will be stored in the input array
volatilityD2
. Only the second order derivative with respect to the forward and strike must be implemented. The array contains [0][0] forward-forward; [0][1] forward-strike; [1][1] strike-strike. Thus the size should be 2 x 2.- Parameters:
forward
- the forward value of the underlyingstrike
- the strike value of the optiontimeToExpiry
- the time to expiry of the optiondata
- the model datavolatilityD
- the array used to return the first order derivativevolatilityD2
- the array of array used to return the second order derivative- Returns:
- the volatility
-
-