C# Класс HullAndWhiteTwoFactors.HW2

Наследование: HW2Context, IExtensibleProcessIR, IZeroRateReference, IMarkovSimulator, IParsable, IPopulable, IGreeksDerivativesInfo, IExportableContainer
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
_a1 IModelParameter
_a2 IModelParameter
_rho IModelParameter
_s1 IModelParameter
_s2 IModelParameter

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
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.

Описание методов

Bond() публичный Метод

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. ///
Результат double

DF() защищенный Метод

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. ///
Результат double

ExportObjects() публичный Метод

Creates a list of all the sub-objects that can be edited.
public ExportObjects ( bool recursive ) : List
recursive bool /// The parameter is not used. ///
Результат List

F() защищенный Метод

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. ///
Результат double

GetDeltaFactors() публичный Метод

Gets the factors for Delta Greek derivative.
public GetDeltaFactors ( ) : IModelParameter[]
Результат IModelParameter[]

GetVegaFactors() публичный Метод

Gets the factors for Vega Greek derivative.
public GetVegaFactors ( ) : IModelParameter[]
Результат IModelParameter[]

GetZeroRateReference() публичный Метод

Gets the zero rate reference.
public GetZeroRateReference ( ) : string
Результат string

HW2() публичный Метод

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
Результат System

Parse() публичный Метод

Parses the data and ensures the parameters are correct.
public Parse ( IProject p_Context ) : bool
p_Context IProject /// The underlying project. ///
Результат bool

Populate() публичный Метод

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.
Результат void

SetZeroRateReference() публичный Метод

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. ///
Результат void

Setup() публичный Метод

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. ///
Результат void

Theta() защищенный Метод

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.
Результат double

a() публичный Метод

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.
Результат void

ab() публичный Метод

public ab ( int i, double x, double a, double b ) : void
i int
x double
a double
b double
Результат void

b() публичный Метод

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.
Результат void

isLog() публичный Метод

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. ///
Результат void

va() публичный Метод

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.
Результат void

Описание свойств

_a1 публичное свойство

Mean-reversion rate for r (short rate).
public IModelParameter _a1
Результат IModelParameter

_a2 публичное свойство

Volatility of r (short rate).
public IModelParameter _a2
Результат IModelParameter

_rho публичное свойство

Mean-reversion rate for u (latent component).
public IModelParameter _rho
Результат IModelParameter

_s1 публичное свойство

Mean-reversion rate for u (latent component).
public IModelParameter _s1
Результат IModelParameter

_s2 публичное свойство

Mean-reversion rate for r (short rate).
public IModelParameter _s2
Результат IModelParameter