Libor.LiborProcess
Class LiborProcess

java.lang.Object
  extended byLibor.LiborProcess.LiborProcess

public class LiborProcess
extends java.lang.Object

The basic class simulating Libor paths as well as the paths of two log-normal approximations (X0,X1, see LiborProcess.ps). Time steps move directly from one point T_i on the Libor tenor structure to the following point T_{i+1} using a predictor corrector simulation. Paths are simulated in the forward martingale measure P_n at the terminal time T=T_n.

This setup can handle all Libor derivatives with payoffs which are deterministic functions of the matrix (L_j(T_k))_{j<=k}) of Libors evaluated at tenor points T_k. This covers caps, swaptions, certain Bermudan swaptions etc. but not derivatives which depend on Libors evaluated more frequently.

The class provides methods to compute Libor sample paths and basic functionals of the Libor path such as zero coupon bonds, annuity numeraires, swap rates etc.

It also provides methods to compute log-normal approximations to certain vectors of Libors which can be simulated directly and used for fast approximate valuation of some Libor derivatives.


Constructor Summary
LiborProcess(double[] l, FactorLoading fl)
           
LiborProcess(LMM_Parameters lmmParams)
          Constructs Libor process from LMM_Parameters parameter object.
 
Method Summary
 double B_pq(int p, int q)
          The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t) at time t=0.
 double b_pq(int p, int q, int t)
          The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t).
 double B_pq(int p, int q, int t)
          The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t).
 double B(double t, double T)
          The zero coupon bond B(t,T) with t<=T arbitrary times.
 double B(int i, int t)
          The zero coupon bond B_i(T_t)=B(s,T) with s=T_t,T=T_i.
 double B0(int i)
          The zero coupon bond B_i(0)=B(0,T_i).
 ColtMatrix correlationMatrix()
          The n by n matrix of instantaneous log-Libor correlations (rho_ij)_{0<=i,j<n}.
 double[] delta()
          The array delta[j]=delta_j of accrual periods.
 int dimension()
          The number n of Libors including L_0.
 FactorLoading factorLoading()
          The FactorLoading of the Libor process
 double forwardTransport(int i)
          Accrual factor 1/B(T_i,T_n)=1/B(n,i).
 double forwardTransport(int t, int i)
          Accrual factor B_i(t)/B_n(t).
 double[] initialTermStructure()
          The array l[j]=L_j(0) of initial Libors.
 RandomVariable L(int j)
          Libor L_j(T_j) as a random variable.
 double L(int j, int t)
          Libor L_j(t), value in current path.
 RandomVariable L0(int j)
          log-Gaussians Libor L^0_j(T_j) as a random variable.
 double L0(int j, int t)
          Gaussian Libor L^0_j(t), value in current path.
 RandomVariable L1(int j)
          log-Gaussian Libor L^1_j(T_j) as a random variable.
 double L1(int j, int t)
          Gaussian Libor L^1_j(t), value in current path.
 ColtMatrix logCovariationCholeskyRoot(int p, int q, double t, double T)
          The Cholesky root of logCovariationMatrix(int,int,double,double).
 ColtMatrix logCovariationMatrix(int p, int q, double t, double T)
          The log-Libor covariation-matrix
 RandomVariable logL(int j)
          Log-Libor log(L_j(T_j)) as a random variable.
 RandomVariable logL0(int j)
          Gaussian log-Libor log(L^0_j(T_j)) as a random variable.
 RandomVariable logL1(int j)
          Gaussian log-Libor log(L^1_j(T_j)) as a random variable.
static void main(java.lang.String[] args)
          Test program.
 void newPath()
          Computes a full Libor path from time zero to the horizon.
 void newPath(boolean Xpath, boolean X0path, boolean X1path)
          Computes a full Libor path from time zero to the horizon.
 void newPath(int T, int p)
          Path of Libors
 void newPath(int T, int p, boolean Xpath, boolean X0path, boolean X1path)
          Path of Libors
 void newPathSegment(int t, int T)
          Special case of newPathSegment(int,int,int).
 void newPathSegment(int t, int T, boolean Xpath, boolean X0path, boolean X1path)
          Special case of newPathSegment(int,int,int,boolean,boolean,boolean).
 void newPathSegment(int t, int T, int p)
          Path of Libors
 void newPathSegment(int t, int T, int p, boolean Xpath, boolean X0path, boolean X1path)
          Path of Libors
 int newPathSegment(int t, Trigger stop)
          Computes a full Libor path from time t to the time the s the trigger stop triggers a stop or to time s=n-1 if no stop is triggered.
 void newWienerIncrements(int t, int T)
          Fills the Z-array with a new set of independent standard normal increments needed to evolve Libors from discrete time t to discrete time T.
 void printCorrelationMatrix()
          Prints the matrix (rho_ij) of instantaneous log-Libor correlations for
 double rho(int i, int j)
          The instantaneous correlations of Libor increments dL_i,dL_j.
 double sigma(int i, int t)
          The deterministic volatility sigma_i(t) of Libor L_i(t).
 double swapRate(int p, int q)
          The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at time t=0.
 double swapRate(int p, int q, int t)
          The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at discrete time t (continuous time T_t).
 double swRate(int p, int q, int t)
          The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at discrete time t (continuous time T_t).
 double[] tenorStructure()
          The array Tc[j]=T_j (continuous times).
 void timeStep(int t, boolean Xpath, boolean X0path, boolean X1path)
          Evolves the full set of Libors from discrete time t to time t+1 in a single time step.
 void timeStep(int t, int p, boolean Xpath, boolean X0path, boolean X1path)
          Evolves the X-Libors L_j(t), j>=p from time T_t (discrete time t) to time T_{t+1} (discrete time t+1) in a single time step.
 java.lang.String toString()
          A message what type of factor loading it is, all the parameter values.
 double vol(int i)
          Annualized volatility of L_i
 double X(int j, int t)
          X-Libor X_j(t)=delta_jL_j(t), value in current path.
 double X0(int j, int t)
          Gaussian X-Libor X^0_j(t), value in current path.
 LiborVector X0LiborVector(int p)
          The vector (X^0_p(T_p),...,X^0_{n-1}(T_p), that is, snapshot of the log-normal X0 Libors X^0_j, j=p,p+1,...,n-1 at time T_p.
 double X1(int j, int t)
          Gaussian X-Libor X^1_j(t), value in current path.
 double[] xInitial()
          The array x[j]=X_j(0) of initial X-Libors.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LiborProcess

public LiborProcess(double[] l,
                    FactorLoading fl)
Parameters:
l - array of initial Libors l[i]=L_i(0).
fl - volatility and correlation structure, see FactorLoading.

LiborProcess

public LiborProcess(LMM_Parameters lmmParams)
Constructs Libor process from LMM_Parameters parameter object.

Parameters:
lmmParams - parameter object.
Method Detail

dimension

public int dimension()
The number n of Libors including L_0.


tenorStructure

public double[] tenorStructure()
The array Tc[j]=T_j (continuous times).


delta

public double[] delta()
The array delta[j]=delta_j of accrual periods.


sigma

public double sigma(int i,
                    int t)

The deterministic volatility sigma_i(t) of Libor L_i(t).

Parameters:
i - Libor index.
t - current discrete time.

rho

public double rho(int i,
                  int j)

The instantaneous correlations of Libor increments dL_i,dL_j. Recall that these are assumed to be constant.

Parameters:
i - Libor index.
j - Libor index.

initialTermStructure

public double[] initialTermStructure()
The array l[j]=L_j(0) of initial Libors.


xInitial

public double[] xInitial()
The array x[j]=X_j(0) of initial X-Libors.


factorLoading

public FactorLoading factorLoading()
The FactorLoading of the Libor process


correlationMatrix

public ColtMatrix correlationMatrix()

The n by n matrix of instantaneous log-Libor correlations (rho_ij)_{0<=i,j<n}. Note that this includes Libor L_0 ie. we are taking the view here that all Libors live to the horizon. See document LiborProcess.ps.


printCorrelationMatrix

public void printCorrelationMatrix()
Prints the matrix (rho_ij) of instantaneous log-Libor correlations for


logCovariationMatrix

public ColtMatrix logCovariationMatrix(int p,
                                       int q,
                                       double t,
                                       double T)

The log-Libor covariation-matrix

CV(p,q,t,T)=( integral_t^T cv_ij(s)ds )_{i,j=p}^{q-1},
cv_ij(s)=sigma_i(s)sigma_j(s)rho_ij=nu_i(s).nu_j(s).

WARNING: index shift to zero based matrix indices (i,j)->(i-p,j-p).

Parameters:
p - Libors L_j, j=p,...,q-1.
q - Libors L_j, j=p,...,q-1.
t - time interval [t,T], continuous time.
T - time interval [t,T], continuous time.

logCovariationCholeskyRoot

public ColtMatrix logCovariationCholeskyRoot(int p,
                                             int q,
                                             double t,
                                             double T)

The Cholesky root of logCovariationMatrix(int,int,double,double).

Parameters:
p - Libors L_j, j=p,...,q-1.
q - Libors L_j, j=p,...,q-1.
t - time interval [t,T], continuous time.
T - time interval [t,T], continuous time.

newWienerIncrements

public void newWienerIncrements(int t,
                                int T)

Fills the Z-array with a new set of independent standard normal increments needed to evolve Libors from discrete time t to discrete time T. It does not matter if the whole set of Libors or a subset is evolved, the same set of Z-increments has to be generated.

Parameters:
t - begining of simulation.
T - end of simulation.

timeStep

public void timeStep(int t,
                     int p,
                     boolean Xpath,
                     boolean X0path,
                     boolean X1path)

Evolves the X-Libors L_j(t), j>=p from time T_t (discrete time t) to time T_{t+1} (discrete time t+1) in a single time step.

Assumes that the array Z of driving Wiener increments has been filled with new values. See document LiborProcessImplementation.ps

Any of the three dynamics X,X0,X1 (see document Liborprocess.ps, section Implementation notes) can be moved forward. Set the corresponding boolean flags to indicate which.

Parameters:
t - current discrete time (continuous time T_t).
p - Libors evolved are L_j, j=p,p+1,...,n-1.
Xpath - do the time step for the X-dynamics (yes/no).
X0path - do the time step for the X0-dynamics (yes/no).
X1path - do the time step for the X1-dynamics (yes/no).

timeStep

public void timeStep(int t,
                     boolean Xpath,
                     boolean X0path,
                     boolean X1path)

Evolves the full set of Libors from discrete time t to time t+1 in a single time step.

Assumes that the array Z of driving Wiener increments has been filled with new values. See document LiborProcessImplementation.ps

Parameters:
t - current discrete time (continuous time T_t).

newPath

public void newPath()
Computes a full Libor path from time zero to the horizon. Moves only the X-Libor path.


newPath

public void newPath(boolean Xpath,
                    boolean X0path,
                    boolean X1path)
Computes a full Libor path from time zero to the horizon. Moves every path for which the flag is set to true.

Parameters:
Xpath - move the X-dynamics.
X0path - move the X0-dynamics.
X1path - move the X1-dynamics.

newPath

public void newPath(int T,
                    int p)

Path of Libors

t\in[0,T] -> (L_p(t),L_{p+1}(t),...,L_{n-1}(t))

ie. the Libors L_j(t), j>=p are computed from discrete time t=0 to discrete time t=T.

Parameters:
T - discrete time up to which Libors are computed.
p - Libors evolved are L_j, j=p,p+1,...,n-1.

newPath

public void newPath(int T,
                    int p,
                    boolean Xpath,
                    boolean X0path,
                    boolean X1path)

Path of Libors

t\in[0,T] -> (L_p(t),L_{p+1}(t),...,L_{n-1}(t))

ie. the Libors L_j(t), j>=p are computed from discrete time t=0 to discrete time t=T.

Parameters:
T - discrete time up to which Libors are computed.
p - Libors evolved are L_j, j=p,p+1,...,n-1.
Xpath - move the X-dynamics.
X0path - move the X0-dynamics.
X1path - move the X1-dynamics.

newPathSegment

public void newPathSegment(int t,
                           int T,
                           int p)

Path of Libors

s\in[t,T] -> (L_p(s),L_{p+1}(s),...,L_{n-1}(s))

ie. continues an existing Libor path from time t to time T. Only the Libors L_j(t), j>=p are computed forward. Of ourse this assumes that these Libors have been computed up to time t. Moves only the X-dynamics.

Conditions the state at time T on the state at time t.

Parameters:
t - time of branching.
p - only L_j, j=p,p+1,...,n-1 computed forward.

newPathSegment

public void newPathSegment(int t,
                           int T)

Special case of newPathSegment(int,int,int). All Libors still alive at time t computed forward. Conditions the state at time T on the state at time t.

Parameters:
t - path segment starts.
T - path segment stops.

newPathSegment

public void newPathSegment(int t,
                           int T,
                           int p,
                           boolean Xpath,
                           boolean X0path,
                           boolean X1path)

Path of Libors

s\in[t,T] -> (L_p(s),L_{p+1}(s),...,L_{n-1}(s))

ie. continues an existing Libor path from time t to time T. Only the Libors L_j(t), j>=p are computed forward. Of ourse this assumes that these Libors have been computed up to time t.

Conditions the state at time T on the state at time t.

Parameters:
t - time of branching.
p - only L_j, j=p,p+1,...,n-1 computed forward.
Xpath - move the X-dynamics.
X0path - move the X0-dynamics.
X1path - move the X1-dynamics.

newPathSegment

public void newPathSegment(int t,
                           int T,
                           boolean Xpath,
                           boolean X0path,
                           boolean X1path)

Special case of newPathSegment(int,int,int,boolean,boolean,boolean). All Libors still alive at time t computed forward. Conditions the state at time T on the state at time t.

Parameters:
t - path segment starts.
T - path segment stops.

newPathSegment

public int newPathSegment(int t,
                          Trigger stop)

Computes a full Libor path from time t to the time the s the trigger stop triggers a stop or to time s=n-1 if no stop is triggered. Moves only the X-Libor path. Triggers must trigger no later than time s=n.

Parameters:
stop - trigger triggering the stop.

L

public double L(int j,
                int t)
Libor L_j(t), value in current path.

Parameters:
t - time.

L0

public double L0(int j,
                 int t)
Gaussian Libor L^0_j(t), value in current path.

Parameters:
j - Libor index.
t - time.

L1

public double L1(int j,
                 int t)
Gaussian Libor L^1_j(t), value in current path.

Parameters:
j - Libor index.
t - time.

X

public double X(int j,
                int t)
X-Libor X_j(t)=delta_jL_j(t), value in current path.

Parameters:
j - Libor index.
t - time.

X0

public double X0(int j,
                 int t)
Gaussian X-Libor X^0_j(t), value in current path.

Parameters:
j - Libor index.
t - time.

X1

public double X1(int j,
                 int t)
Gaussian X-Libor X^1_j(t), value in current path.

Parameters:
j - Libor index.
t - time.

vol

public double vol(int i)
Annualized volatility of L_i

Parameters:
i - Libor index.

L

public RandomVariable L(int j)
Libor L_j(T_j) as a random variable.

Parameters:
j - Libor index.

L0

public RandomVariable L0(int j)
log-Gaussians Libor L^0_j(T_j) as a random variable.

Parameters:
j - Libor index.

L1

public RandomVariable L1(int j)
log-Gaussian Libor L^1_j(T_j) as a random variable.

Parameters:
j - Libor index.

logL

public RandomVariable logL(int j)
Log-Libor log(L_j(T_j)) as a random variable.

Parameters:
j - Libor index.

logL0

public RandomVariable logL0(int j)
Gaussian log-Libor log(L^0_j(T_j)) as a random variable.

Parameters:
j - Libor index.

logL1

public RandomVariable logL1(int j)
Gaussian log-Libor log(L^1_j(T_j)) as a random variable.

Parameters:
j - Libor index.

X0LiborVector

public LiborVector X0LiborVector(int p)

The vector (X^0_p(T_p),...,X^0_{n-1}(T_p), that is, snapshot of the log-normal X0 Libors X^0_j, j=p,p+1,...,n-1 at time T_p.

This vector is highly correlated to the true Libors at time T_p and allows very fast direct simulation (the logarithms are multinormal). Used for log-normal approximate pricing and in control variates.

WARNING: no conditioning, time t ignored, sampling corresponds to Libor path computation from time t=0.

Parameters:
p - Libors X_j(T_p), j>=p. Must satisfy p<n.

B0

public double B0(int i)
The zero coupon bond B_i(0)=B(0,T_i).

Parameters:
i - bond matures at time T_i

B

public double B(int i,
                int t)
The zero coupon bond B_i(T_t)=B(s,T) with s=T_t,T=T_i. Assumes that all Libors L_k, k=t,t+1,...,n-1 have been computed up to time s=T_t (discrete time t).

Parameters:
t - bond evaluated at time T_t
i - bond matures at time T_i, must satisfy t<=i.

forwardTransport

public double forwardTransport(int t,
                               int i)

Accrual factor B_i(t)/B_n(t). This factor shifts a cashflow from time T_i to the horizon T_n with Libors in state at time T_t (discrete time t). In other words the shift is carried out at discrete time t.

Needs all Libors L_j, j>=i up to time T_t (discrete time t).

Parameters:
t - current discrete time (continuous time T_t).
i - cashflow shifted from time T_i to horizon.

forwardTransport

public double forwardTransport(int i)

Accrual factor 1/B(T_i,T_n)=1/B(n,i). This factor shifts a cashflow from time T_i to the horizon T_n with Libors in state at time T_i.

Needs all Libors L_j, j>=i up to time T_i (discrete time i).

Parameters:
i - cashflow shifted from time T_i to horizon.

B

public double B(double t,
                double T)

The zero coupon bond B(t,T) with t<=T arbitrary times. Simple discounting on subintervals of Libor accrual intervals.

Note: since Libors are not available at time t they are evaluated at the time T_i closest to t. Consequently this is only an approximation to the zero coupon bond B(t,T). In fact this bond can be computed accurately in the LMM only if both t and T coincide with Libor reset times.

Needs all Libors L_j, j>=i up to time T_{i+1} where T_i<=t.

Parameters:
t - current continuous time.
T - continuous time of bond maturity, must satsisfy t<=T.

swRate

public double swRate(int p,
                     int q,
                     int t)

The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at discrete time t (continuous time T_t). Needs all Libors L_j, j>=p up to time t.

Straightforward implementation following the definition. Extremely inefficient. Used only to test the correctness of the streamlined implementation.

Parameters:
p - swap begins at T_p.
q - swap ends at T_q (settled).
t - current (discrete) time.

swapRate

public double swapRate(int p,
                       int q,
                       int t)

The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at discrete time t (continuous time T_t). Needs all Libors L_j, j>=p up to time t.

Parameters:
p - swap begins at T_p.
q - swap ends at T_q (settled).
t - current (discrete) time.

swapRate

public double swapRate(int p,
                       int q)

The forward swap rate S_pq(t)=k(t,[T_p,T_q]) at time t=0.

Parameters:
p - swap begins at T_p.
q - swap ends at T_q (settled).

b_pq

public double b_pq(int p,
                   int q,
                   int t)

The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t). Needs all Libors L_j, j>=p+1 up to time t.

Straightforward implementation following the definition. Extremely inefficient. Used only to test the correctness of the streamlined implementation.

Parameters:
p - annuity begins at T_p.
q - annuity ends at T_q (settled).
t - current (discrete) time.

B_pq

public double B_pq(int p,
                   int q,
                   int t)

The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t). Needs all Libors L_j, j>=p+1 up to time t.

Parameters:
p - annuity begins at T_p.
q - annuity ends at T_q (settled).
t - current (discrete) time.

B_pq

public double B_pq(int p,
                   int q)

The annuity B_pq(t)=sum_{k=p}^{q-1}delta_kB_{k+1}(t) at time t=0.

Parameters:
p - annuity begins at T_p.
q - annuity ends at T_q (settled).

toString

public java.lang.String toString()
A message what type of factor loading it is, all the parameter values.


main

public static void main(java.lang.String[] args)

Test program. Allocates sample Libor process in dimension n=20 then computes a histogram of L_12(T_12).

Sample size: 50,000 paths.