Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

DriftlessLMM.h

Go to the documentation of this file.
00001 /* WARANTY NOTICE AND COPYRIGHT
00002 This program is free software; you can redistribute it and/or
00003 modify it under the terms of the GNU General Public License
00004 as published by the Free Software Foundation; either version 2
00005 of the License, or (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program; if not, write to the Free Software
00014 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00015 
00016 Copyright (C) Michael J. Meyer
00017 
00018 matmjm@mindspring.com
00019 spyqqqdia@yahoo.com
00020 
00021 */
00022 
00023 
00024 #ifndef martingale_driftlesslmm_h    
00025 #define martingale_driftlesslmm_h
00026 
00027 #include "TypedefsMacros.h"
00028 #include "LiborMarketModel.h"               // base class
00029 #include "Matrix.h"                         // direct members
00030 
00031 MTGL_BEGIN_NAMESPACE(Martingale)
00032 
00033 
00034 
00035 // dependencies
00036 class StochasticGenerator;       // StochasticGenerator.h
00037 class SobolLiborDriver;
00038 class MonteCarloLiborDriver;
00039 class LiborFactorLoading;        // LiborFactorLoading.h
00040 // class UTRRealMatrix;
00041 // class RealArray1D;
00042 // class RealVector;
00043 
00044 
00045 
00052 /*******************************************************************************
00053  *
00054  *                                 DriftlessLMM
00055  *
00056  ******************************************************************************/ 
00057 
00058 
00092 class DriftlessLMM : public LiborMarketModel {
00093 
00094         
00095         // Row t is used to drive the time step T_t->T_{t+1}
00096         // This is allocated as an n-dimensional matrix to preserve natural indexation
00097         // Row index starts at zero, first column not needed, see newWienerIncrements.
00098         UTRRealMatrix Z;
00099     
00100     // The following are allocated as lower triangular arrays:
00101     
00102     // Array containing the X-Libors X(t,j)=X_j(T_t)=delta_jL_j(T_t), t<=j.
00103     // The rows are the vectors X(T_t)=(X_t(T_t),...,X_{n-1}(T_t)).
00104     UTRRealMatrix U;
00105     
00106     // Array containing the log-Libors Y(t,j)=Y_j(T_t)=log(X_j(T_t)), t<=j.
00107     // The rows are the vectors Y(T_t)=(Y_t(T_t),...,Y_{n-1}(T_t)).
00108     UTRRealMatrix Y;
00109         
00110         // accrual factors H(t,j)=H_j(T_t)=B_j(T_t)/B_n(T_t), t<=j.
00111         // we take this up to j=n where H(t,n)=1 to avoid messy code.
00112         UTRRealMatrix H;         
00113  
00114         
00115         // Array containing the deterministic drift steps
00116     // m(t,j)=-0.5*integral_{T_t}^{T_{t+1}}sigma^2_j(s)ds of the log(U_j).
00117     UTRRealMatrix m;
00118     
00119     // volatility step vector
00120     RealArray1D V;
00121     
00122  
00123     // the log(U_j) covariation matrices of the needed for the time steps
00124     UTRMatrixSequence logLiborCovariationMatrices;
00125                 
00126     // the upper triangular roots of the above covariation matrices
00127     UTRMatrixSequence logLiborCovariationMatrixRoots;
00128         
00129         
00130     StochasticGenerator* SG;    // generates the Wiener increments driving the paths     
00131         
00132         RealVector XVec;          // cache for fast returning of X-Libor vectors.
00133   
00134 
00135 public:
00136 
00139     void switchToQMC();
00140         
00141         
00144     void switchToMC();
00145         
00146 
00147 
00148 
00149 // LIBORS
00150 
00151      
00157      Real XL(int j, int t) const;
00158          
00159          
00166       const RealVector& XLvect(int t, int p);
00167                  
00168 
00169         
00170 //  CONSTRUCTOR
00171 
00172     
00178     DriftlessLMM(LiborFactorLoading* fl);
00179         
00180         
00181                 
00188         static LiborMarketModel* sample(int n, int volType, int corrType);
00189 
00190 
00191     
00192 
00193 // WIENER INCREMENTS
00194 
00199      void newWienerIncrements(int t);
00200         
00201         
00205         void printWienerIncrements(int t, int s) const;
00206         
00207         
00218         int effectiveDimension(int t, int s) const { return (s-t)*(2*n-(1+t+s))/2; }
00219 
00220 
00221                 
00222                 
00223 // TIME STEP
00224 
00225     
00226 
00235      void timeStep(int t, int p);
00236                 
00237      
00244      void timeStep(int t){ timeStep(t,t+1); }
00245      
00246      
00247 
00248 //  OVERRIDE lIBOR VOLATLTIES    
00249 //  FASTER VERSIONS OF BONDS, SWAPRATES,...
00250      
00251 
00256      Real vol(int i) const;
00257          
00258      
00259 
00260 
00261 // FORWARD TRANSPORTING FACTORS
00262          
00263          
00264                  
00268      Real H_i0(int i) const;
00269      
00270 
00280      Real H_it(int i, int t);
00281 
00282 
00283      
00289      Real H_ii(int i);
00290          
00291          
00298      Real H_pq(int p, int q, int t);
00299 
00300 
00301  
00302          
00303               
00304 // ZERO COUPON BONDS 
00305 
00306 
00311      Real B0(int i) const;
00312 
00313  
00321     Real B(int i, int t);
00322 
00323         
00324 
00325      
00326 
00327          
00328 // FORWARD SWAP RATES                      
00329              
00330 
00331      
00339      Real swapRate(int p, int q, int t);
00340 
00341 
00346      Real swapRate(int p, int q) { return swapRate(p,q,0); } 
00347 
00348  
00349          
00350          
00351 // ANNUITY NUMERAIRE
00352                   
00353      
00354      
00361      Real B_pq(int p, int q, int t);
00362 
00363      
00369      Real B_pq(int p, int q) { return B_pq(p,q,0); }
00370          
00371          
00372          
00373 // SWAPTION AND CAPLET AGGREGATE VOLATILITIES (SIGMA)
00374          
00383      Real capletAggregateVolatility(int i) const;
00384          
00385          
00395      Real swaptionAggregateVolatility(int p, int q, int t) const;
00396 
00397 
00405      Real bondAggregateVolatility(Bond* B, int t) const;
00406 
00407 
00408          
00409 // STRING MESSAGE
00410     
00411     
00414     std::ostream& printSelf(std::ostream& os) const;
00415          
00416              
00417 
00418 }; // end DriftlessLMM
00419 
00420 
00421 
00422 MTGL_END_NAMESPACE(Martingale)  
00423 
00424 #endif
00425 
00426 

Generated on Mon Sep 22 02:16:32 2003 for Libor-Library by doxygen1.3-rc3