# Extended Cox-Ingersoll-Ross Model¶

## Overview¶

In financial mathematics, by replacing the coefficients in the Cox-Ingersoll-Ross model with the time varying functions, the Extended Cox-Ingersoll-Ross (ECIR) model is a mathematical model of the term structure of interest rates. It is a type of “one factor model” (short rate model) as it describes interest rate movements as driven by only one source of market risk. The model can be used in the valuation of interest rate derivatives (from Wiki).

## Implementation¶

This section mainly introduces the implementation process of short-rate and discount, which is applied in Tree Engine. They are core part for option pricing.

As a critical part of Tree Engine, the class $$ECIRModel$$ implements the single-factor ECIR model to calculate short-rate and discount, by using continuous compounding. The implementation process is introduced as follows.

1. The short-rate is calculated at time point $$t$$ with the duration $$dt$$ from 0 to N point-by-point by functions treeShortRate, initRate and iterRate. As the core part of the treeShortRate, the outer loop_rateModel is used to ensure the results under pre-specified tolerance. For the internal functions, the functionality of initRate and iterRate is similar with each other, but initRate can produce 3 intermediate results while the iterRate gives only one per iteration. In order to achieve intiation interval (II)=1, the array values16 is added to store the intermediate results. Then an addtion tree is performed subsequently for the whole process.
2. For implementing the generic Tree framework, the $$state\_price$$ calculating process is moved from Tree Lattice to this Model.
1. The discount is calculated at time point $$t$$ with the duration $$dt$$ based on the short-rate.