C# Class HullAndWhiteTwoFactors.HW2

Inheritance: HW2Context, IExtensibleProcessIR, IZeroRateReference, IMarkovSimulator, IParsable, IPopulable, IGreeksDerivativesInfo, IExportableContainer
Afficher le fichier Open project: fairmat/InterestRatesModels

Méthodes publiques

Свойство Type Description
_a1 IModelParameter
_a2 IModelParameter
_rho IModelParameter
_s1 IModelParameter
_s2 IModelParameter

Méthodes publiques

Méthode Description
Bond ( IReadOnlyMatrixSlice dynamic, double dates, int i, double t, double s ) : double

Calculates the value of a Bond under the Hull and White Two factors model.

ExportObjects ( bool recursive ) : List

Creates a list of all the sub-objects that can be edited.

GetDeltaFactors ( ) : IModelParameter[]

Gets the factors for Delta Greek derivative.

GetVegaFactors ( ) : IModelParameter[]

Gets the factors for Vega Greek derivative.

GetZeroRateReference ( ) : string

Gets the zero rate reference.

HW2 ( ) : System

Initializes a new instance of the HullAndWhiteTwoFactors.HW2 class. This is the default constructor and sets the default values of several components of the model: * alpha 1 = 0.1 * sigma 1 = 0.001 * alpha 2 = 0.01 * sigma 2 = 0.001 * rho = 0.001 * No zero rate. * drift correction = 0.

Parse ( IProject p_Context ) : bool

Parses the data and ensures the parameters are correct.

Populate ( string names, double values ) : void

Populate editable fields from name and value vectors specific to HW2.

SetZeroRateReference ( string zr ) : void

Associate the process to a zero rate defined in the Fairmat model (e.g. @zr1).

Setup ( double dates ) : void

Called by Simulator after parse. Initializes here time-dependant but not state dependent variables.

a ( int i, double x, double a ) : void

This function calculates the drift in the HW2 Markov process.

ab ( int i, double x, double a, double b ) : void
b ( int i, double x, double b ) : void

This function updates the volatility parameters (vector b) of the HW2 process.

isLog ( bool &isLog ) : void

Sets the passed array with a Booleans stating if the process components must be simulated as a log-normal process.

va ( int i, System.Matrix x, System.Matrix a ) : void

Vectorial version of method a.

Méthodes protégées

Méthode Description
DF ( double t, double dt ) : double

Numerically calculates the derivative of function F().

F ( double t, double dt ) : double

Numerically calculates the instantaneous forward rate.

Theta ( double t, double dt ) : double

Calculates the theta element of the Hull And White formula which will be stored in the theta in order to be used during simulation.

Private Methods

Méthode Description
BondHW2 ( Project context, SPCache cache, HW2Context hw2, double R, double u, double PT, double P_t, double Pdt, double TT, double t, double dt ) : double

Price of a zcb at t > 0 with maturity TT > t as a function of the rate R, of the factor u at t and of the current zr curve (ZR) using the Hull & White two-factor model

dr = (theta(t) + u - a * r) * dt + sigma1 * dz1 du = -b * du * dt + sigma2 * dz2 with dz1 * dz2 = rho * dt

(see Hull-White (1994) Journal of Derivatives).

CalculateInnerModelParameters ( ) : void

Calculates and caches the model parameters for use during the simulation.

DPhi ( double t, double dt ) : double

Calculates either the right numerical derivative or the central numerical derivative of Phi.

OnDeserialized ( StreamingContext context ) : void
Phi ( double t ) : double

Calculates the standard normal cumulative distribution function.

Preprocessing ( ) : void

Does a preliminary processing of all the parameters and required data which will be used during the simulation.

ZCB ( double t ) : double

Calculates the value of a Zero Coupon Bond.

Zr ( double t ) : double

Evaluates the referenced zr.

Method Details

Bond() public méthode

Calculates the value of a Bond under the Hull and White Two factors model.
public Bond ( IReadOnlyMatrixSlice dynamic, double dates, int i, double t, double s ) : double
dynamic IReadOnlyMatrixSlice /// The simulated process. ///
dates double /// The vector of reference dates. ///
i int /// The index at which the state variables must be sampled. ///
t double /// The date in years/fractions at at which the state variables must be sampled. ///
s double /// The maturity of the bond. ///
Résultat double

DF() protected méthode

Numerically calculates the derivative of function F().
protected DF ( double t, double dt ) : double
t double /// Time at which calculate the derivative. ///
dt double /// Semi-interval to be used in the numerical derivative. ///
Résultat double

ExportObjects() public méthode

Creates a list of all the sub-objects that can be edited.
public ExportObjects ( bool recursive ) : List
recursive bool /// The parameter is not used. ///
Résultat List

F() protected méthode

Numerically calculates the instantaneous forward rate.
protected F ( double t, double dt ) : double
t double /// Time at which calculate the forward rate. ///
dt double /// Interval to be used in the numerical derivative. ///
Résultat double

GetDeltaFactors() public méthode

Gets the factors for Delta Greek derivative.
public GetDeltaFactors ( ) : IModelParameter[]
Résultat IModelParameter[]

GetVegaFactors() public méthode

Gets the factors for Vega Greek derivative.
public GetVegaFactors ( ) : IModelParameter[]
Résultat IModelParameter[]

GetZeroRateReference() public méthode

Gets the zero rate reference.
public GetZeroRateReference ( ) : string
Résultat string

HW2() public méthode

Initializes a new instance of the HullAndWhiteTwoFactors.HW2 class. This is the default constructor and sets the default values of several components of the model: * alpha 1 = 0.1 * sigma 1 = 0.001 * alpha 2 = 0.01 * sigma 2 = 0.001 * rho = 0.001 * No zero rate. * drift correction = 0.
public HW2 ( ) : System
Résultat System

Parse() public méthode

Parses the data and ensures the parameters are correct.
public Parse ( IProject p_Context ) : bool
p_Context IProject /// The underlying project. ///
Résultat bool

Populate() public méthode

Populate editable fields from name and value vectors specific to HW2.
public Populate ( string names, double values ) : void
names string /// An array with the names of the variable, /// will search for alpha1 (or a1), sigma1 (or sigma), alpha2 (or a2), sigma2 and rho. ///
values double The values associated to the parameters in names.
Résultat void

SetZeroRateReference() public méthode

Associate the process to a zero rate defined in the Fairmat model (e.g. @zr1).
public SetZeroRateReference ( string zr ) : void
zr string /// The zero rate reference. ///
Résultat void

Setup() public méthode

Called by Simulator after parse. Initializes here time-dependant but not state dependent variables.
public Setup ( double dates ) : void
dates double /// The dates at which the process realizations will be requested. ///
Résultat void

Theta() protected méthode

Calculates the theta element of the Hull And White formula which will be stored in the theta in order to be used during simulation.
protected Theta ( double t, double dt ) : double
t double The position in which this value will be calculated.
dt double The delta between this t position and the previous one.
Résultat double

a() public méthode

This function calculates the drift in the HW2 Markov process.
public a ( int i, double x, double a ) : void
i int The time step of the simulation.
x double The state vector at the previous state.
a double The drift,output of the function.
Résultat void

ab() public méthode

public ab ( int i, double x, double a, double b ) : void
i int
x double
a double
b double
Résultat void

b() public méthode

This function updates the volatility parameters (vector b) of the HW2 process.
public b ( int i, double x, double b ) : void
i int The parameter is not used.
x double The parameter is not used.
b double The output of the function.
Résultat void

isLog() public méthode

Sets the passed array with a Booleans stating if the process components must be simulated as a log-normal process.
public isLog ( bool &isLog ) : void
isLog bool /// A reference to the array to be set with the required information. ///
Résultat void

va() public méthode

Vectorial version of method a.
public va ( int i, System.Matrix x, System.Matrix a ) : void
i int The discrete time-step.
x System.Matrix The actual state matrix.
a System.Matrix The output drift matrix.
Résultat void

Property Details

_a1 public_oe property

Mean-reversion rate for r (short rate).
public IModelParameter _a1
Résultat IModelParameter

_a2 public_oe property

Volatility of r (short rate).
public IModelParameter _a2
Résultat IModelParameter

_rho public_oe property

Mean-reversion rate for u (latent component).
public IModelParameter _rho
Résultat IModelParameter

_s1 public_oe property

Mean-reversion rate for u (latent component).
public IModelParameter _s1
Résultat IModelParameter

_s2 public_oe property

Mean-reversion rate for r (short rate).
public IModelParameter _s2
Résultat IModelParameter