C# Class Pelsser.SquaredGaussianModel

Inheritance: IExtensibleProcessIR, IZeroRateReference, IMarkovSimulator, IParsable, IPostSimulationTransformation, IPopulable, IVectorialMarkovSimulator, IGreeksDerivativesInfo, IOpenCLCode, IExportableContainer
Show file Open project: fairmat/InterestRatesModels Class Usage Examples

Public Properties

Property Type Description
a1 IModelParameter
lamda0 IModelParameter
sigma1 IModelParameter

Public Methods

Method Description
A ( int ti, int si, double delta, double btT ) : double

Calculates the function A(t, T) of the model, which is an integral.

AlphaT ( int i ) : double

Gets alphaT at the position i.

B ( int ti, int si, double delta ) : double[]

Calculates the function B(t, T) of the model, which is an integral, for all elements.

BSingle ( int ti, int si, double delta ) : double

Calculates the function B(t, T) of the model, which is an integral, for a single element.

Bond ( IReadOnlyMatrixSlice dynamic, double dates, int i, double t, double s ) : double

Calculates the value of a Bond under the Pelsser model.

C ( double deltaT ) : double

Calculates the C(t, T) function of the model.

CalculateGamma ( ) : void

This will simply calculate the gamma factor used in the Pelsser formulation and set the relative temporary variable.

Gamma = sqrt(a^2 + 2 * sigma^2).

D ( double deltaT ) : double

Calculates the D(t, T) function of the model.

ExportObjects ( bool recursive ) : List

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

F ( double T, double dt ) : double

Calculates F(T, dt) of the model.

F2 ( double T, double dt ) : double

Calculates F(T, dt) of the model, but doesn't apply the square root. This value is, as such equal to F-squared.

GetDeltaFactors ( ) : IModelParameter[]

Returns the factors for Delta/Gamma Greek derivatives. In this case none so null is returned.

GetVegaFactors ( ) : IModelParameter[]

Returns the factors for Vega Greek derivative. In this case just sigma1.

GetZeroRateReference ( ) : string

Gets the zero rate reference.

Int ( double t1, double t2 ) : double

Calculates the integral inside alpha(T).

Mu0 ( double T ) : double

Calculates the mu(t, T, y) used by the Caplets.

Parse ( IProject p_Context ) : bool

Ensure the parameters are correct.

Populate ( string names, double values ) : void

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

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.

SquaredGaussianModel ( ) : System

Default constructor. Builds a new SquaredGaussianModel with these default values: * sigma = 0.06. * lambda = 0.4. * alpha = 0.09. * no zero rate reference.

SquaredGaussianModel ( double sigma, double lambda, double a1, string zeroRateReference ) : System

Constructor which builds a new SquareGaussianModel with provided values.

Transform ( double dates, IMatrixSlice outDynamic ) : void

Handles the conversion, after the simulation, from y to the rate r.

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

This function defines the drift in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State.

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

This function defines the drift and the volatility in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State. B = sigma.

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

This function defines the volatility in the Pelsser Markov process. The formula to calculate the B component is B = sigma.

f ( double t, double dt ) : double

Calculates the instantaneous forward.

isLog ( bool &isLog ) : void

Sets the passed array with a Boolean stating if the process must be simulated as a log-normal process. In this case it should not.

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

This function defines the drift in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State. This is the version which handles a vectorial execution.

vb ( int i, Matrix x, Matrix b ) : void

This function defines the volatility in the Pelsser markov process. The formula to calculate the B component is B = sigma. This is the version which handles a vectorial execution.

Protected Methods

Method Description
SIG ( double deltaT ) : double

Represents the variance of the model.

Private Methods

Method Description
CalculateValueForCache ( double dates ) : void

Precalculates several values and functions of the model in order to cache them for later use.

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

Helper function to make functions easier to read. Just returns the value of the zero rate at position t.

Method Details

A() public method

Calculates the function A(t, T) of the model, which is an integral.
public A ( int ti, int si, double delta, double btT ) : double
ti int The starting Index from where to calculate.
si int The ending Index of the integration.
delta double The delta of time where to execute the calculation.
btT double /// A populated array with the results of the function B(s, T) of the model. ///
return double

AlphaT() public method

Gets alphaT at the position i.
public AlphaT ( int i ) : double
i int The position where to get the alphaT value.
return double

B() public method

Calculates the function B(t, T) of the model, which is an integral, for all elements.
public B ( int ti, int si, double delta ) : double[]
ti int The starting Index from where to calculate.
si int The ending Index of the integration.
delta double The delta of time where to execute the calculation.
return double[]

BSingle() public method

Calculates the function B(t, T) of the model, which is an integral, for a single element.
public BSingle ( int ti, int si, double delta ) : double
ti int The starting Index from where to calculate.
si int The ending Index of the integration.
delta double The delta of time where to execute the calculation.
return double

Bond() public method

Calculates the value of a Bond under the Pelsser 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. ///
return double

C() public method

Calculates the C(t, T) function of the model.
public C ( double deltaT ) : double
deltaT double The delta between T and t.
return double

CalculateGamma() public method

This will simply calculate the gamma factor used in the Pelsser formulation and set the relative temporary variable.
Gamma = sqrt(a^2 + 2 * sigma^2).
public CalculateGamma ( ) : void
return void

D() public method

Calculates the D(t, T) function of the model.
public D ( double deltaT ) : double
deltaT double The delta between T and t.
return double

ExportObjects() public method

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

F() public method

Calculates F(T, dt) of the model.
public F ( double T, double dt ) : double
T double The time where to calculate the function.
dt double /// The delta of time to consider to calculate the function. ///
return double

F2() public method

Calculates F(T, dt) of the model, but doesn't apply the square root. This value is, as such equal to F-squared.
public F2 ( double T, double dt ) : double
T double The time where to calculate the function.
dt double /// The delta of time to consider to calculate the function. ///
return double

GetDeltaFactors() public method

Returns the factors for Delta/Gamma Greek derivatives. In this case none so null is returned.
public GetDeltaFactors ( ) : IModelParameter[]
return IModelParameter[]

GetVegaFactors() public method

Returns the factors for Vega Greek derivative. In this case just sigma1.
public GetVegaFactors ( ) : IModelParameter[]
return IModelParameter[]

GetZeroRateReference() public method

Gets the zero rate reference.
public GetZeroRateReference ( ) : string
return string

Int() public method

Calculates the integral inside alpha(T).
public Int ( double t1, double t2 ) : double
t1 double The starting point of the integration.
t2 double The ending point of the integration.
return double

Mu0() public method

Calculates the mu(t, T, y) used by the Caplets.
public Mu0 ( double T ) : double
T double The span of time to calculate the function on.
return double

Parse() public method

Ensure the parameters are correct.
public Parse ( IProject p_Context ) : bool
p_Context IProject /// The underlying project. ///
return bool

Populate() public method

Populate editable fields from name and value vectors specific to Pelsser.
public Populate ( string names, double values ) : void
names string /// An array with the names of the variable, /// will search for alpha1 (or a), sigma1 (or sigma) and lamba0. ///
values double The values associated to the parameters in names.
return void

SIG() protected method

Represents the variance of the model.
protected SIG ( double deltaT ) : double
deltaT double The delta between T and t.
return double

SetZeroRateReference() public method

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. ///
return void

Setup() public method

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. ///
return void

SquaredGaussianModel() public method

Default constructor. Builds a new SquaredGaussianModel with these default values: * sigma = 0.06. * lambda = 0.4. * alpha = 0.09. * no zero rate reference.
public SquaredGaussianModel ( ) : System
return System

SquaredGaussianModel() public method

Constructor which builds a new SquareGaussianModel with provided values.
public SquaredGaussianModel ( double sigma, double lambda, double a1, string zeroRateReference ) : System
sigma double The sigma factor of the model.
lambda double The parameter is not used.
a1 double The alpha factor of the model.
zeroRateReference string A reference to a zero rate.
return System

Transform() public method

Handles the conversion, after the simulation, from y to the rate r.
public Transform ( double dates, IMatrixSlice outDynamic ) : void
dates double The parameter is not used.
outDynamic IMatrixSlice The input and output components of the transformation.
return void

a() public method

This function defines the drift in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State.
public a ( int i, double x, double a ) : void
i int The parameter is not used.
x double The state vector at the previous state.
a double The output of the function.
return void

ab() public method

This function defines the drift and the volatility in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State. B = sigma.
public ab ( int i, double x, double a, double b ) : void
i int The parameter is not used.
x double The state vector at the previous state.
a double The output drift.
b double
return void

b() public method

This function defines the volatility in the Pelsser Markov process. The formula to calculate the B component is B = sigma.
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.
return void

f() public method

Calculates the instantaneous forward.
public f ( double t, double dt ) : double
t double The time where to calculate the instantaneous forward.
dt double /// The delta of time to consider to calculate the instantaneous forward. ///
return double

isLog() public method

Sets the passed array with a Boolean stating if the process must be simulated as a log-normal process. In this case it should not.
public isLog ( bool &isLog ) : void
isLog bool /// A reference to the array to be set with the required information. ///
return void

va() public method

This function defines the drift in the Pelsser Markov process. The formula to calculate the A component is A = - alpha * previous State. This is the version which handles a vectorial execution.
public va ( int i, Matrix x, Matrix a ) : void
i int The parameter is not used.
x Matrix The state Matrix at the previous state.
a Matrix The output of the function.
return void

vb() public method

This function defines the volatility in the Pelsser markov process. The formula to calculate the B component is B = sigma. This is the version which handles a vectorial execution.
public vb ( int i, Matrix x, Matrix b ) : void
i int The parameter is not used.
x Matrix The parameter is not used.
b Matrix The output of the function.
return void

Property Details

a1 public property

The mean reversion rate.
public IModelParameter a1
return IModelParameter

lamda0 public property

Market price of risk.
public IModelParameter lamda0
return IModelParameter

sigma1 public property

The diffusion parameter.
public IModelParameter sigma1
return IModelParameter