Module net.finmath.lib
Class HullWhiteModelWithConstantCoeff
java.lang.Object
net.finmath.montecarlo.model.AbstractProcessModel
net.finmath.montecarlo.interestrate.models.HullWhiteModelWithConstantCoeff
- All Implemented Interfaces:
IndependentModelParameterProvider,LIBORModel,TermStructureModel,ProcessModel
Implements a Hull-White model with constant coefficients.
A more general implementation of the Hull-White model can be found in
HullWhiteModel.
For details and documentation please see HullWhiteModel for real applications.
- Version:
- 1.0
- Author:
- Christian Fries
-
Constructor Summary
ConstructorsConstructorDescriptionHullWhiteModelWithConstantCoeff(TimeDiscretization liborPeriodDiscretization, AnalyticModel analyticModel, ForwardCurve forwardRateCurve, DiscountCurve discountCurve, double meanReversion, double volatility, Map<String,?> properties)Creates a Hull-White model which implementsLIBORMarketModel. -
Method Summary
Modifier and TypeMethodDescriptionapplyStateSpaceTransform(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Applies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.applyStateSpaceTransformInverse(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Applies the inverse state space transform f-1i to the given random variable such that Xi → f-1i(Xi) =: Yi.Return the associated analytic model, a collection of market date object like discount curve, forward curve and volatility surfaces.getCloneWithModifiedData(Map<String,Object> dataModified)Create a new object implementing LIBORModel, using the new data.Return the discount curve associated the forwards.getDrift(MonteCarloProcess process, int timeIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)This method has to be implemented to return the drift, i.e.getFactorLoading(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex)This method has to be implemented to return the factor loadings, i.e.getForwardRate(MonteCarloProcess process, double time, double periodStart, double periodEnd)Returns the time \( t \) forward rate on the models forward curve.Return the initial forward rate curve.getInitialState(MonteCarloProcess process)Returns the initial value of the state variable of the process Y, not to be confused with the initial value of the model X (which is the state space transform applied to this state value.doublegetIntegratedBondSquaredVolatility(double time, double maturity)getLIBOR(MonteCarloProcess process, int timeIndex, int liborIndex)Return the forward rate at a given timeIndex and for a given liborIndex.doublegetLiborPeriod(int timeIndex)The period start corresponding to a given forward rate discretization index.The tenor time discretization of the forward rate curve.intgetLiborPeriodIndex(double time)Same as java.util.Arrays.binarySearch(liborPeriodDiscretization,time).Returns a map of independent model parameters of this model.intReturns the number of componentsintReturns the number of factors m, i.e., the number of independent Brownian drivers.intGet the number of LIBORs in the LIBOR discretization.getNumeraire(MonteCarloProcess process, double time)Return the numeraire at a given time index.getRandomVariableForConstant(double value)Return a random variable initialized with a constant using the models random variable factory.doublegetShortRateConditionalVariance(double time, double maturity)Calculates the variance \( \mathop{Var}(r(t) \vert r(s) ) \), that is \( \int_{s}^{t} \sigma^{2}(\tau) \exp(-2 \cdot a \cdot (t-\tau)) \ \mathrm{d}\tau \) where \( a \) is the meanReversion and \( \sigma \) is the short rate instantaneous volatility.Methods inherited from class net.finmath.montecarlo.model.AbstractProcessModel
getInitialValue, getReferenceDateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.finmath.montecarlo.model.ProcessModel
getReferenceDateMethods inherited from interface net.finmath.montecarlo.interestrate.TermStructureModel
getForwardDiscountBond, getLIBOR
-
Constructor Details
-
HullWhiteModelWithConstantCoeff
public HullWhiteModelWithConstantCoeff(TimeDiscretization liborPeriodDiscretization, AnalyticModel analyticModel, ForwardCurve forwardRateCurve, DiscountCurve discountCurve, double meanReversion, double volatility, Map<String,?> properties)Creates a Hull-White model which implementsLIBORMarketModel.- Parameters:
liborPeriodDiscretization- The forward rate discretization to be used in thegetLIBORmethod.analyticModel- The analytic model to be used (currently not used, may be null).forwardRateCurve- The forward curve to be used (currently not used, - the model uses disocuntCurve only.discountCurve- The disocuntCurve (currently also used to determine the forward curve).meanReversion- The mean reversion speed parameter a.volatility- The short rate volatility \( \sigma \).properties- A map specifying model properties (currently not used, may be null).
-
-
Method Details
-
getNumberOfComponents
public int getNumberOfComponents()Description copied from interface:ProcessModelReturns the number of components- Specified by:
getNumberOfComponentsin interfaceProcessModel- Returns:
- The number of components
-
getNumberOfFactors
public int getNumberOfFactors()Description copied from interface:ProcessModelReturns the number of factors m, i.e., the number of independent Brownian drivers.- Specified by:
getNumberOfFactorsin interfaceProcessModel- Returns:
- The number of factors.
-
applyStateSpaceTransform
public RandomVariable applyStateSpaceTransform(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Description copied from interface:ProcessModelApplies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.- Specified by:
applyStateSpaceTransformin interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex- The time index (related to the model times discretization).componentIndex- The component index i.randomVariable- The state random variable Yi.- Returns:
- New random variable holding the result of the state space transformation.
-
applyStateSpaceTransformInverse
public RandomVariable applyStateSpaceTransformInverse(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable randomVariable)Description copied from interface:ProcessModelApplies the inverse state space transform f-1i to the given random variable such that Xi → f-1i(Xi) =: Yi.- Specified by:
applyStateSpaceTransformInversein interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex- The time index (related to the model times discretization).componentIndex- The component index i.randomVariable- The state random variable Xi.- Returns:
- New random variable holding the result of the state space transformation.
-
getInitialState
Description copied from interface:ProcessModelReturns the initial value of the state variable of the process Y, not to be confused with the initial value of the model X (which is the state space transform applied to this state value.- Specified by:
getInitialStatein interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.- Returns:
- The initial value of the state variable of the process Y(t=0).
-
getNumeraire
public RandomVariable getNumeraire(MonteCarloProcess process, double time) throws CalculationExceptionDescription copied from interface:ProcessModelReturn the numeraire at a given time index. Note: The random variable returned is a defensive copy and may be modified.- Specified by:
getNumerairein interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.time- The time t for which the numeraire N(t) should be returned.- Returns:
- The numeraire at the specified time as
RandomVariable - Throws:
CalculationException- Thrown if the valuation fails, specific cause may be available via thecause()method.
-
getDrift
public RandomVariable[] getDrift(MonteCarloProcess process, int timeIndex, RandomVariable[] realizationAtTimeIndex, RandomVariable[] realizationPredictor)Description copied from interface:ProcessModelThis method has to be implemented to return the drift, i.e. the coefficient vector
μ = (μ1, ..., μn) such that X = f(Y) and
dYj = μj dt + λ1,j dW1 + ... + λm,j dWm
in an m-factor model. Here j denotes index of the component of the resulting process. Since the model is provided only on a time discretization, the method may also (should try to) return the drift as \( \frac{1}{t_{i+1}-t_{i}} \int_{t_{i}}^{t_{i+1}} \mu(\tau) \mathrm{d}\tau \).- Specified by:
getDriftin interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex- The time index (related to the model times discretization).realizationAtTimeIndex- The given realization at timeIndexrealizationPredictor- The given realization attimeIndex+1or null if no predictor is available.- Returns:
- The drift or average drift from timeIndex to timeIndex+1, i.e. \( \frac{1}{t_{i+1}-t_{i}} \int_{t_{i}}^{t_{i+1}} \mu(\tau) \mathrm{d}\tau \) (or a suitable approximation).
-
getFactorLoading
public RandomVariable[] getFactorLoading(MonteCarloProcess process, int timeIndex, int componentIndex, RandomVariable[] realizationAtTimeIndex)Description copied from interface:ProcessModelThis method has to be implemented to return the factor loadings, i.e. the coefficient vector
λj = (λ1,j, ..., λm,j) such that X = f(Y) and
dYj = μj dt + λ1,j dW1 + ... + λm,j dWm
in an m-factor model. Here j denotes index of the component of the resulting process.- Specified by:
getFactorLoadingin interfaceProcessModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex- The time index (related to the model times discretization).componentIndex- The index j of the driven component.realizationAtTimeIndex- The realization of X at the time corresponding to timeIndex (in order to implement local and stochastic volatlity models).- Returns:
- The factor loading for given factor and component.
-
getRandomVariableForConstant
Description copied from interface:ProcessModelReturn a random variable initialized with a constant using the models random variable factory.- Specified by:
getRandomVariableForConstantin interfaceProcessModel- Parameters:
value- The constant value.- Returns:
- A new random variable initialized with a constant value.
-
getForwardRate
public RandomVariable getForwardRate(MonteCarloProcess process, double time, double periodStart, double periodEnd) throws CalculationExceptionDescription copied from interface:TermStructureModelReturns the time \( t \) forward rate on the models forward curve. Note: It is guaranteed that the random variable returned by this method is \( \mathcal{F}_{t} ) \)-measurable.- Specified by:
getForwardRatein interfaceTermStructureModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.time- The evaluation time.periodStart- The period start of the forward rate.periodEnd- The period end of the forward rate.- Returns:
- The forward rate.
- Throws:
CalculationException- Thrown if model fails to calculate the random variable.
-
getLIBOR
public RandomVariable getLIBOR(MonteCarloProcess process, int timeIndex, int liborIndex) throws CalculationExceptionDescription copied from interface:LIBORModelReturn the forward rate at a given timeIndex and for a given liborIndex.- Specified by:
getLIBORin interfaceLIBORModel- Parameters:
process- The discretization process generating this model. The process provides call backs for TimeDiscretization and allows calls to getProcessValue for timeIndices less or equal the given one.timeIndex- The time index (associated withProcess.getTimeDiscretization().liborIndex- The forward rate index (associated withLIBORModel.getLiborPeriodDiscretization().- Returns:
- The forward rate.
- Throws:
CalculationException- Thrown if calculation failed.
-
getLiborPeriodDiscretization
Description copied from interface:LIBORModelThe tenor time discretization of the forward rate curve.- Specified by:
getLiborPeriodDiscretizationin interfaceLIBORModel- Returns:
- The tenor time discretization of the forward rate curve.
-
getNumberOfLibors
public int getNumberOfLibors()Description copied from interface:LIBORModelGet the number of LIBORs in the LIBOR discretization.- Specified by:
getNumberOfLiborsin interfaceLIBORModel- Returns:
- The number of LIBORs in the LIBOR discretization
-
getLiborPeriod
public double getLiborPeriod(int timeIndex)Description copied from interface:LIBORModelThe period start corresponding to a given forward rate discretization index.- Specified by:
getLiborPeriodin interfaceLIBORModel- Parameters:
timeIndex- The index corresponding to a given time (interpretation is start of period)- Returns:
- The period start corresponding to a given forward rate discretization index.
-
getLiborPeriodIndex
public int getLiborPeriodIndex(double time)Description copied from interface:LIBORModelSame as java.util.Arrays.binarySearch(liborPeriodDiscretization,time). Will return a negative value if the time is not found, but then -index-1 corresponds to the index of the smallest time greater than the given one.- Specified by:
getLiborPeriodIndexin interfaceLIBORModel- Parameters:
time- The period start.- Returns:
- The index corresponding to a given time (interpretation is start of period)
-
getAnalyticModel
Description copied from interface:TermStructureModelReturn the associated analytic model, a collection of market date object like discount curve, forward curve and volatility surfaces.- Specified by:
getAnalyticModelin interfaceTermStructureModel- Returns:
- The associated analytic model.
-
getDiscountCurve
Description copied from interface:TermStructureModelReturn the discount curve associated the forwards.- Specified by:
getDiscountCurvein interfaceTermStructureModel- Returns:
- the discount curve associated the forwards.
-
getForwardRateCurve
Description copied from interface:TermStructureModelReturn the initial forward rate curve.- Specified by:
getForwardRateCurvein interfaceTermStructureModel- Returns:
- the forward rate curve
-
getCloneWithModifiedData
Description copied from interface:LIBORModelCreate a new object implementing LIBORModel, using the new data.- Specified by:
getCloneWithModifiedDatain interfaceLIBORModel- Specified by:
getCloneWithModifiedDatain interfaceProcessModel- Specified by:
getCloneWithModifiedDatain interfaceTermStructureModel- Parameters:
dataModified- A map with values to be used in constructions (keys are identical to parameter names of the constructors).- Returns:
- A new object implementing LIBORModel, using the new data.
-
getShortRateConditionalVariance
public double getShortRateConditionalVariance(double time, double maturity)Calculates the variance \( \mathop{Var}(r(t) \vert r(s) ) \), that is \( \int_{s}^{t} \sigma^{2}(\tau) \exp(-2 \cdot a \cdot (t-\tau)) \ \mathrm{d}\tau \) where \( a \) is the meanReversion and \( \sigma \) is the short rate instantaneous volatility.- Parameters:
time- The parameter s in \( \int_{s}^{t} \sigma^{2}(\tau) \exp(-2 \cdot a \cdot (t-\tau)) \ \mathrm{d}\tau \)maturity- The parameter t in \( \int_{s}^{t} \sigma^{2}(\tau) \exp(-2 \cdot a \cdot (t-\tau)) \ \mathrm{d}\tau \)- Returns:
- The integrated square volatility.
-
getIntegratedBondSquaredVolatility
public double getIntegratedBondSquaredVolatility(double time, double maturity) -
getModelParameters
Description copied from interface:IndependentModelParameterProviderReturns a map of independent model parameters of this model.- Specified by:
getModelParametersin interfaceIndependentModelParameterProvider- Returns:
- Map of independent model parameters of this model.
-