Class SmileModelFitter<T extends SmileModelData>
- java.lang.Object
-
- com.opengamma.strata.pricer.impl.volatility.smile.SmileModelFitter<T>
-
- Type Parameters:
T
- the data of smile model to be calibrated
- Direct Known Subclasses:
SabrModelFitter
public abstract class SmileModelFitter<T extends SmileModelData> extends Object
Smile model fitter.Attempts to calibrate a smile model to the implied volatilities of European vanilla options, by minimising the sum of squares between the market and model implied volatilities.
All the options must be for the same expiry and (implicitly) on the same underlying.
-
-
Constructor Summary
Constructors Constructor Description SmileModelFitter(double forward, DoubleArray strikes, double timeToExpiry, DoubleArray impliedVols, DoubleArray error, VolatilityFunctionProvider<T> model)
Constructs smile model fitter from forward, strikes, time to expiry, implied volatilities and error values.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected Function<DoubleArray,Boolean>
getConstraintFunction(NonLinearParameterTransforms t)
Obtains the constraint function.protected abstract DoubleArray
getMaximumStep()
Obtains the maximum number of iterations.VolatilityFunctionProvider<T>
getModel()
Obtains the volatility function provider.protected Function<DoubleArray,DoubleMatrix>
getModelJacobianFunction()
Obtains Jacobian function of the smile model.protected Function<DoubleArray,DoubleArray>
getModelValueFunction()
Obtains volatility function of the smile model.protected abstract NonLinearParameterTransforms
getTransform(DoubleArray start)
Obtains the nonlinear transformation of parameters from the initial values.protected abstract NonLinearParameterTransforms
getTransform(DoubleArray start, BitSet fixed)
Obtains the nonlinear transformation of parameters from the initial values with some parameters fixed.LeastSquareResultsWithTransform
solve(DoubleArray start)
Solves using the default NonLinearParameterTransforms for the concrete implementation.LeastSquareResultsWithTransform
solve(DoubleArray start, NonLinearParameterTransforms transform)
Solve using a user supplied NonLinearParameterTransforms.LeastSquareResultsWithTransform
solve(DoubleArray start, BitSet fixed)
Solve using the default NonLinearParameterTransforms for the concrete implementation with some parameters fixed to their initial values (indicated by fixed).abstract T
toSmileModelData(DoubleArray modelParameters)
ObtainsSmileModelData
instance from the model parameters.
-
-
-
Constructor Detail
-
SmileModelFitter
public SmileModelFitter(double forward, DoubleArray strikes, double timeToExpiry, DoubleArray impliedVols, DoubleArray error, VolatilityFunctionProvider<T> model)
Constructs smile model fitter from forward, strikes, time to expiry, implied volatilities and error values.strikes
,impliedVols
anderror
should be the same length and ordered coherently.- Parameters:
forward
- the forward value of the underlyingstrikes
- the ordered values of strikestimeToExpiry
- the time-to-expiryimpliedVols
- the market implied volatilitieserror
- the 'measurement' error to apply to the market volatility of a particular option TODO: Review should this be part of EuropeanOptionMarketData?model
- the volatility function provider
-
-
Method Detail
-
solve
public LeastSquareResultsWithTransform solve(DoubleArray start)
Solves using the default NonLinearParameterTransforms for the concrete implementation.This returns
LeastSquareResults
.- Parameters:
start
- the first guess at the parameter values- Returns:
- the calibration results
-
solve
public LeastSquareResultsWithTransform solve(DoubleArray start, BitSet fixed)
Solve using the default NonLinearParameterTransforms for the concrete implementation with some parameters fixed to their initial values (indicated by fixed).This returns
LeastSquareResults
.- Parameters:
start
- the first guess at the parameter valuesfixed
- the parameters are fixed- Returns:
- the calibration results
-
solve
public LeastSquareResultsWithTransform solve(DoubleArray start, NonLinearParameterTransforms transform)
Solve using a user supplied NonLinearParameterTransforms.This returns
LeastSquareResults
.- Parameters:
start
- the first guess at the parameter valuestransform
- transform from model parameters to fitting parameters, and vice versa- Returns:
- the calibration results
-
getModelValueFunction
protected Function<DoubleArray,DoubleArray> getModelValueFunction()
Obtains volatility function of the smile model.The function is defined in
VolatilityFunctionProvider
.- Returns:
- the function
-
getModelJacobianFunction
protected Function<DoubleArray,DoubleMatrix> getModelJacobianFunction()
Obtains Jacobian function of the smile model.The function is defined in
VolatilityFunctionProvider
.- Returns:
- the function
-
getMaximumStep
protected abstract DoubleArray getMaximumStep()
Obtains the maximum number of iterations.- Returns:
- the maximum number.
-
getTransform
protected abstract NonLinearParameterTransforms getTransform(DoubleArray start)
Obtains the nonlinear transformation of parameters from the initial values.- Parameters:
start
- the initial values- Returns:
- the nonlinear transformation
-
getTransform
protected abstract NonLinearParameterTransforms getTransform(DoubleArray start, BitSet fixed)
Obtains the nonlinear transformation of parameters from the initial values with some parameters fixed.- Parameters:
start
- the initial valuesfixed
- the parameters are fixed- Returns:
- the nonlinear transformation
-
toSmileModelData
public abstract T toSmileModelData(DoubleArray modelParameters)
ObtainsSmileModelData
instance from the model parameters.- Parameters:
modelParameters
- the model parameters- Returns:
- the smile model data
-
getConstraintFunction
protected Function<DoubleArray,Boolean> getConstraintFunction(NonLinearParameterTransforms t)
Obtains the constraint function.This is defaulted to be "unconstrained".
- Parameters:
t
- the nonlinear transformation- Returns:
- the constraint function
-
getModel
public VolatilityFunctionProvider<T> getModel()
Obtains the volatility function provider.- Returns:
- the volatility function provider
-
-