C# Class CIRProcess.CIR2

Inheritance: IExtensibleProcess, IPopulable, IMarkovSimulator, IParsable, IPostSimulationTransformation, IDefaultProbabiliy, IExportableContainer
Show file Open project: fairmat/InterestRatesModels

Public Properties

Property Type Description
k1 IModelParameter
k2 IModelParameter
sigma1 IModelParameter
sigma2 IModelParameter
startingValue1 IModelParameter
startingValue2 IModelParameter
theta1 IModelParameter
theta2 IModelParameter

Public Methods

Method Description
CDSDefaultP ( IReadOnlyMatrixSlice dynamic, double dates, int j, double t ) : double

Calculates the probability of a default at date t (conditional of being in a given state (realization) of process s1, s2), being on period s = dates[j].

CIR2 ( ) : System

Default constructor which prepares an instance of the two factors Cox-Ingersoll-Ross model with some sample values.

DefaultValues ( ) : void

Sets the default values for the components.

ExportObjects ( bool recursive ) : List

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

Parse ( IProject context ) : bool

Ensure the parameters are correct.

Populate ( string names, double values ) : void

This is part of the IPopulable interface but it's not implemented.

Setup ( double simulationDates ) : void

Called by Simulator after parse. In this case does nothing.

Transform ( double dates, IMatrixSlice outDynamic ) : void

Calculates the probabilities for one scenario.

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

This function defines the drift in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the A component is A[0] = k1 * (theta1 - previous state) A[1] = k2 * (theta2 - previous state).

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

This function calculated drift and volatility in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the B component is B[0] = sqrt(previous state) * sigma1 B[1] = sqrt(previous state) * sigma2.

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

This function defines the volatility in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the B component is B[0] = sqrt(previous state) * sigma1 B[1] = sqrt(previous state) * sigma2.

isLog ( bool &isLog ) : void

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

Private Methods

Method Description
AdjSqrt ( double x ) : double

Checks if the value is negative and floors it to zero, instead of attempting a square root of negative numbers.

GetZR ( double t ) : double

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

SetDescription ( ) : void

Sets the descriptions for the components.

Method Details

CDSDefaultP() public method

Calculates the probability of a default at date t (conditional of being in a given state (realization) of process s1, s2), being on period s = dates[j].
public CDSDefaultP ( IReadOnlyMatrixSlice dynamic, double dates, int j, double t ) : double
dynamic IReadOnlyMatrixSlice The underlying's realizations.
dates double The corresponding underlying's dates.
j int The wanted date index.
t double The date at which we want to estimate the default prob.
return double

CIR2() public method

Default constructor which prepares an instance of the two factors Cox-Ingersoll-Ross model with some sample values.
public CIR2 ( ) : System
return System

DefaultValues() public method

Sets the default values for the components.
public DefaultValues ( ) : void
return void

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

Parse() public method

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

Populate() public method

This is part of the IPopulable interface but it's not implemented.
public Populate ( string names, double values ) : void
names string The parameter is not used.
values double The parameter is not used.
return void

Setup() public method

Called by Simulator after parse. In this case does nothing.
public Setup ( double simulationDates ) : void
simulationDates double The parameter is not used.
return void

Transform() public method

Calculates the probabilities for one scenario.
public Transform ( double dates, IMatrixSlice outDynamic ) : void
dates double Dates (in Year fractions).
outDynamic IMatrixSlice Input and output matrix.
return void

a() public method

This function defines the drift in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the A component is A[0] = k1 * (theta1 - previous state) A[1] = k2 * (theta2 - 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 calculated drift and volatility in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the B component is B[0] = sqrt(previous state) * sigma1 B[1] = sqrt(previous state) * sigma2.
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
b double The output drift.
return void

b() public method

This function defines the volatility in the Cox-Ingersoll-Ross Two factors Markov process. The formula to calculate the B component is B[0] = sqrt(previous state) * sigma1 B[1] = sqrt(previous state) * sigma2.
public b ( int i, double x, double b ) : void
i int The parameter is not used.
x double The state vector at the previous state.
b double The output of the function.
return void

isLog() public method

Sets the passed array with a Boolean stating if the process 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. /// The array contains a two members set to false as this simulation /// is not log-normal. ///
return void

Property Details

k1 public property

The mean reversion speed (first component).
public IModelParameter k1
return IModelParameter

k2 public property

The mean reversion speed (second component).
public IModelParameter k2
return IModelParameter

sigma1 public property

The volatility (first component).
public IModelParameter sigma1
return IModelParameter

sigma2 public property

The volatility (second component).
public IModelParameter sigma2
return IModelParameter

startingValue1 public property

The starting value for the process (first component).
public IModelParameter startingValue1
return IModelParameter

startingValue2 public property

The starting value for the process (second component).
public IModelParameter startingValue2
return IModelParameter

theta1 public property

The long term mean (first component).
public IModelParameter theta1
return IModelParameter

theta2 public property

The long term mean (second component).
public IModelParameter theta2
return IModelParameter