finMath lib documentation
net.finmath.montecarlo.interestrate

## Class HullWhiteModelWithDirectSimulation

• All Implemented Interfaces:
LIBORModelInterface, TermStructureModelInterface, AbstractModelInterface

public class HullWhiteModelWithDirectSimulation
extends AbstractModel
implements LIBORModelInterface
Implements a Hull-White model with time dependent mean reversion speed and time dependent short rate volatility. Note: This implementation is for illustrative purposes. For a numerically equivalent, more efficient implementation see HullWhiteModel. Please use HullWhiteModel for real applications.

Model Dynamics

The Hull-While model assumes the following dynamic for the short rate: $d r(t) = ( \theta(t) - a(t) r(t) ) d t + \sigma(t) d W(t) \text{,} \quad r(t_{0}) = r_{0} \text{,}$ where the function $$\theta$$ determines the calibration to the initial forward curve, $$a$$ is the mean reversion and $$\sigma$$ is the instantaneous volatility. The dynamic above is under the equivalent martingale measure corresponding to the numeraire $N(t) = \exp\left( \int_0^t r(\tau) \mathrm{d}\tau \right) \text{.}$ The main task of this class is to provide the risk-neutral drift and the volatility to the numerical scheme (given the volatility model), simulating $$r(t_{i})$$. The class then also provides and the corresponding numeraire and forward rates (LIBORs).

Time Discrete Model

Assuming piecewise constant coefficients (mean reversion speed $$a$$ and short rate volatility $$\sigma$$ the class specifies the drift and factor loadings as piecewise constant functions for an Euler-scheme. The class provides the exact Euler step for the short rate r. More specifically (assuming a constant mean reversion speed $$a$$ for a moment), considering $\Delta \bar{r}(t_{i}) = \frac{1}{t_{i+1}-t_{i}} \int_{t_{i}}^{t_{i+1}} d r(t)$ we find from $\exp(-a t) \ \left( \mathrm{d} \left( \exp(a t) r(t) \right) \right) \ = \ a r(t) + \mathrm{d} r(t) \ = \ \theta(t) \mathrm{d}t + \sigma(t) \mathrm{d}W(t)$ that $\exp(a t_{i+1}) r(t_{i+1}) - \exp(a t_{i}) r(t_{i}) \ = \ \int_{t_{i}}^{t_{i+1}} \left[ \exp(a t) \theta(t) \mathrm{d}t + \exp(a t) \sigma(t) \mathrm{d}W(t) \right]$ that is $r(t_{i+1}) - r(t_{i}) \ = \ -(1-\exp(-a (t_{i+1}-t_{i})) r(t_{i}) + \int_{t_{i}}^{t_{i+1}} \left[ \exp(-a (t_{i+1}-t)) \theta(t) \mathrm{d}t + \exp(-a (t_{i+1}-t)) \sigma(t) \mathrm{d}W(t) \right]$ Assuming piecewise constant $$\sigma$$ and $$\theta$$, being constant over $$(t_{i},t_{i}+\Delta t_{i})$$, we thus find $r(t_{i+1}) - r(t_{i}) \ = \ \frac{1-\exp(-a \Delta t_{i})}{a \Delta t_{i}} \left( ( \theta(t_{i}) - a \bar{r}(t_{i})) \Delta t_{i} \right) + \sqrt{\frac{1-\exp(-2 a \Delta t_{i})}{2 a \Delta t_{i}}} \sigma(t_{i}) \Delta W(t_{i})$ . In other words, the Euler scheme is exact if the mean reversion $$a$$ is replaced by the effective mean reversion $$\frac{1-\exp(-a \Delta t_{i})}{a \Delta t_{i}} a$$ and the volatility is replaced by the effective volatility $$\sqrt{\frac{1-\exp(-2 a \Delta t_{i})}{2 a \Delta t_{i}}} \sigma(t_{i})$$. In the calculations above the mean reversion speed is treated as a constants, but it is straight forward to see that the same holds for piecewise constant mean reversion speeds, replacing the expression $$a \ t$$ by $$\int_{0}^t a(s) \mathrm{d}s$$.

Calibration

The drift of the short rate is calibrated to the given forward curve using $\theta(t) = \frac{\partial}{\partial T} f(0,t) + a(t) f(0,t) + \phi(t) \text{,}$ where the function $$f$$ denotes the instantanenous forward rate and $$\phi(t) = \frac{1}{2} a \sigma^{2}(t) B(t)^{2} + \sigma^{2}(t) B(t) \frac{\partial}{\partial t} B(t)$$ with $$B(t) = \frac{1-\exp(-a t)}{a}$$.

Volatility Model

The Hull-White model is essentially equivalent to LIBOR Market Model where the forward rate normal volatility $$\sigma(t,T)$$ is given by $\sigma(t,T_{i}) \ = \ (1 + L_{i}(t) (T_{i+1}-T_{i})) \sigma(t) \exp(-a (T_{i}-t)) \frac{1-\exp(-a (T_{i+1}-T_{i}))}{a (T_{i+1}-T_{i})}$ (where $$\{ T_{i} \}$$ is the forward rates tenor time discretization (note that this is the normal volatility, not the log-normal volatility). Hence, we interpret both, short rate mean reversion speed and short rate volatility as part of the volatility model. The mean reversion speed and the short rate volatility have to be provided to this class via an object implementing ShortRateVolailityModelInterface.
Version:
1.2
Author:
Christian Fries
ShortRateVolailityModelInterface, HullWhiteModel
• ### Constructor Summary

Constructors
Constructor and Description
HullWhiteModelWithDirectSimulation(TimeDiscretizationInterface liborPeriodDiscretization, AnalyticModelInterface analyticModel, ForwardCurveInterface forwardRateCurve, DiscountCurveInterface discountCurve, ShortRateVolailityModelInterface volatilityModel, Map<String,?> properties)
Creates a Hull-White model which implements LIBORMarketModelInterface.
• ### Method Summary

All Methods
Modifier and Type Method and Description
RandomVariableInterface applyStateSpaceTransform(int componentIndex, RandomVariableInterface randomVariable)
Applies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.
RandomVariableInterface applyStateSpaceTransformInverse(int componentIndex, RandomVariableInterface randomVariable)
AnalyticModelInterface getAnalyticModel()
Return the associated analytic model, a collection of market date object like discount curve, forward curve and volatility surfaces.
LIBORMarketModelInterface getCloneWithModifiedData(Map<String,Object> dataModified)
Create a new object implementing LIBORModelInterface, using the new data.
DiscountCurveInterface getDiscountCurve()
Return the discount curve associated the forwards.
RandomVariableInterface[] getDrift(int timeIndex, RandomVariableInterface[] realizationAtTimeIndex, RandomVariableInterface[] realizationPredictor)
This method has to be implemented to return the drift, i.e.
RandomVariableInterface[] getFactorLoading(int timeIndex, int componentIndex, RandomVariableInterface[] realizationAtTimeIndex)
This method has to be implemented to return the factor loadings, i.e.
ForwardCurveInterface getForwardRateCurve()
Return the initial forward rate curve.
RandomVariableInterface[] getInitialState()
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.
double getIntegratedBondSquaredVolatility(double time, double maturity)
RandomVariableInterface getLIBOR(double time, double periodStart, double periodEnd)
RandomVariableInterface getLIBOR(int timeIndex, int liborIndex)
double getLiborPeriod(int timeIndex)
The period start corresponding to a given forward rate discretization index.
TimeDiscretizationInterface getLiborPeriodDiscretization()
The tenor time discretization of the forward rate curve.
int getLiborPeriodIndex(double time)
Same as java.util.Arrays.binarySearch(liborPeriodDiscretization,time).
int getNumberOfComponents()
Returns the number of components
int getNumberOfLibors()
Get the number of LIBORs in the LIBOR discretization.
RandomVariableInterface getNumeraire(double time)
Return the numeraire at a given time index.
RandomVariableInterface getRandomVariableForConstant(double value)
Return a random variable initialized with a constant using the models random variable factory.
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 \int_{\tau}^{t} a(u) \mathrm{d}u ) \ \mathrm{d}\tau$$ where $$a$$ is the meanReversion and $$\sigma$$ is the short rate instantaneous volatility.
• ### Methods inherited from class net.finmath.montecarlo.model.AbstractModel

getInitialValue, getMonteCarloWeights, getNumberOfFactors, getProcess, getProcessValue, getTime, getTimeDiscretization, getTimeIndex, setProcess
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Methods inherited from interface net.finmath.montecarlo.model.AbstractModelInterface

getNumberOfFactors, getProcess, getTimeDiscretization, setProcess
• ### Constructor Detail

• #### HullWhiteModelWithDirectSimulation

public HullWhiteModelWithDirectSimulation(TimeDiscretizationInterface liborPeriodDiscretization,
AnalyticModelInterface analyticModel,
ForwardCurveInterface forwardRateCurve,
DiscountCurveInterface discountCurve,
ShortRateVolailityModelInterface volatilityModel,
Map<String,?> properties)
Creates a Hull-White model which implements LIBORMarketModelInterface.
Parameters:
liborPeriodDiscretization - The forward rate discretization to be used in the getLIBOR method.
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).
volatilityModel - The volatility model specifying mean reversion and instantaneous volatility of the short rate.
properties - A map specifying model properties (currently not used, may be null).
• ### Method Detail

• #### getNumberOfComponents

public int getNumberOfComponents()
Description copied from interface: AbstractModelInterface
Returns the number of components
Specified by:
getNumberOfComponents in interface AbstractModelInterface
Returns:
The number of components
• #### applyStateSpaceTransform

public RandomVariableInterface applyStateSpaceTransform(int componentIndex,
RandomVariableInterface randomVariable)
Description copied from interface: AbstractModelInterface
Applies the state space transform fi to the given state random variable such that Yi → fi(Yi) =: Xi.
Specified by:
applyStateSpaceTransform in interface AbstractModelInterface
Parameters:
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 RandomVariableInterface applyStateSpaceTransformInverse(int componentIndex,
RandomVariableInterface randomVariable)
Specified by:
applyStateSpaceTransformInverse in interface AbstractModelInterface
• #### getInitialState

public RandomVariableInterface[] getInitialState()
Description copied from interface: AbstractModelInterface
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.
Specified by:
getInitialState in interface AbstractModelInterface
Returns:
The initial value of the state variable of the process Y(t=0).
• #### getNumeraire

public RandomVariableInterface getNumeraire(double time)
throws CalculationException
Description copied from interface: AbstractModelInterface
Return the numeraire at a given time index. Note: The random variable returned is a defensive copy and may be modified.
Specified by:
getNumeraire in interface AbstractModelInterface
Parameters:
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 the cause() method.
• #### getDrift

public RandomVariableInterface[] getDrift(int timeIndex,
RandomVariableInterface[] realizationAtTimeIndex,
RandomVariableInterface[] realizationPredictor)
Description copied from interface: AbstractModelInterface
This 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:
getDrift in interface AbstractModelInterface
Parameters:
timeIndex - The time index (related to the model times discretization).
realizationAtTimeIndex - The given realization at timeIndex
realizationPredictor - The given realization at timeIndex+1 or 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).
• #### getRandomVariableForConstant

public RandomVariableInterface getRandomVariableForConstant(double value)
Description copied from interface: AbstractModelInterface
Return a random variable initialized with a constant using the models random variable factory.
Specified by:
getRandomVariableForConstant in interface AbstractModelInterface
Parameters:
value - The constant value.
Returns:
A new random variable initialized with a constant value.

public RandomVariableInterface[] getFactorLoading(int timeIndex,
int componentIndex,
RandomVariableInterface[] realizationAtTimeIndex)
Description copied from interface: AbstractModelInterface
This 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:
getFactorLoading in interface AbstractModelInterface
Parameters:
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:
• #### getLIBOR

public RandomVariableInterface getLIBOR(double time,
double periodStart,
double periodEnd)
throws CalculationException
Specified by:
getLIBOR in interface TermStructureModelInterface
Throws:
CalculationException
• #### getLIBOR

public RandomVariableInterface getLIBOR(int timeIndex,
int liborIndex)
throws CalculationException
Specified by:
getLIBOR in interface LIBORModelInterface
Throws:
CalculationException
• #### getLiborPeriodDiscretization

public TimeDiscretizationInterface getLiborPeriodDiscretization()
Description copied from interface: LIBORModelInterface
The tenor time discretization of the forward rate curve.
Specified by:
getLiborPeriodDiscretization in interface LIBORModelInterface
Returns:
The tenor time discretization of the forward rate curve.
• #### getNumberOfLibors

public int getNumberOfLibors()
Description copied from interface: LIBORModelInterface
Get the number of LIBORs in the LIBOR discretization.
Specified by:
getNumberOfLibors in interface LIBORModelInterface
Returns:
The number of LIBORs in the LIBOR discretization
• #### getLiborPeriod

public double getLiborPeriod(int timeIndex)
Description copied from interface: LIBORModelInterface
The period start corresponding to a given forward rate discretization index.
Specified by:
getLiborPeriod in interface LIBORModelInterface
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: LIBORModelInterface
Same 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:
getLiborPeriodIndex in interface LIBORModelInterface
Parameters:
time - The period start.
Returns:
The index corresponding to a given time (interpretation is start of period)
• #### getAnalyticModel

public AnalyticModelInterface getAnalyticModel()
Description copied from interface: TermStructureModelInterface
Return the associated analytic model, a collection of market date object like discount curve, forward curve and volatility surfaces.
Specified by:
getAnalyticModel in interface TermStructureModelInterface
Returns:
The associated analytic model.
• #### getDiscountCurve

public DiscountCurveInterface getDiscountCurve()
Description copied from interface: TermStructureModelInterface
Return the discount curve associated the forwards.
Specified by:
getDiscountCurve in interface TermStructureModelInterface
Returns:
the discount curve associated the forwards.
• #### getForwardRateCurve

public ForwardCurveInterface getForwardRateCurve()
Description copied from interface: TermStructureModelInterface
Return the initial forward rate curve.
Specified by:
getForwardRateCurve in interface TermStructureModelInterface
Returns:
the forward rate curve
• #### getCloneWithModifiedData

public LIBORMarketModelInterface getCloneWithModifiedData(Map<String,Object> dataModified)
Description copied from interface: LIBORModelInterface
Create a new object implementing LIBORModelInterface, using the new data.
Specified by:
getCloneWithModifiedData in interface LIBORModelInterface
Specified by:
getCloneWithModifiedData in interface TermStructureModelInterface
Specified by:
getCloneWithModifiedData in interface AbstractModelInterface
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 LIBORModelInterface, 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 \int_{\tau}^{t} a(u) \mathrm{d}u ) \ \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 \int_{\tau}^{t} a(u) \mathrm{d}u ) \ \mathrm{d}\tau$$
maturity - The parameter t in $$\int_{s}^{t} \sigma^{2}(\tau) \exp(-2 \cdot \int_{\tau}^{t} a(u) \mathrm{d}u ) \ \mathrm{d}\tau$$
Returns:
The conditional variance of the short rate, $$\mathop{Var}(r(t) \vert r(s) )$$.
• #### getIntegratedBondSquaredVolatility

public double getIntegratedBondSquaredVolatility(double time,
double maturity)