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

LmmLattice.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 #ifndef martingale_lmmlattice_h    
00024 #define martingale_lmmlattice_h
00025 
00026 // template class LmmLattice must be fully defined in header
00027 #include "TypedefsMacros.h"
00028 #include "Lattice.h"              // base class
00029 #include "Node.h"                 // base class
00030 #include "Utils.h"
00031 #include "Array.h"                // direct member
00032 #include "Matrix.h"               // direct member
00033 #include "LiborFactorLoading.h" 
00034 #include "Node.h"                 // problem with typedefed forward declarations
00035 
00036 
00037 class std::ostream;
00038 
00039 
00040 
00041 MTGL_BEGIN_NAMESPACE(Martingale)
00042 
00043 
00044 // forward declaration
00045 class BondCall;
00046 
00047 
00118 /**********************************************************************************
00119  *
00120  *            GENERAL LMM LATTICE
00121  *
00122  *********************************************************************************/
00123  
00124  
00125         
00126  
00127 
00133 class LmmLattice : public Lattice<StandardBrownianNode> {
00134         
00135 protected:
00136         
00137         // factor loading of the underlying driftless LMM
00138         LiborFactorLoading* factorLoading; 
00139         
00140         int n,                  // dimension (number of accrual intervals)
00141             r,                  // number of factors
00142             nSteps;             // number of time steps in each accrual interval
00143         
00145         Real delta;
00147         Real dt;
00149         Real a;
00151         RealArray1D sg;
00153         RealArray1D log_U0;
00155         RealArray1D mu;  
00157         RealMatrix R;     
00158 
00159         
00160 public:
00161 
00162 
00164 int getNumberOfFactors(){ return r; }
00165 
00167 LiborFactorLoading* getFactorLoading(){ return factorLoading; } 
00168         
00170 int getSteps(){ return nSteps; }
00171         
00173 Real getTimeStep(){ return delta/nSteps; }
00174 
00178 int getTenor(int s){ return (int)(s*dt/delta); }
00179 
00183 Real transitionProbability(int i){ return 1.0/(1<<r); }
00184 
00185                 
00186 // CONSTRUCTOR
00187         
00195 LmmLattice(int q, LiborFactorLoading* fl, int t, int steps=1, bool verbose=false);
00196 
00197 virtual ~LmmLattice(){ }
00198 
00199 
00200 // SAMPLE LATTICE AND TEST
00201 
00206 static LmmLattice* sample(int r, int n, int p, int nSteps, bool verbose=false);
00207 
00208 
00216 void rescaleVols();
00217 
00219 void testFactorization() const;
00220 
00221 std::ostream& printSelf(std::ostream& os) const;
00222 
00223 
00228 static void test(int r, int n);
00229 
00230 
00231 // LIBOR PATH FUNCTIONALS
00232 
00241 // The parameters is only needed to recognize the case s=0.
00242 // It then propagates through all functions using this one.
00243 // Keep it anyway, it might be useful for more complicated option payoffs.
00244 const RealArray1D& Hvect(int p, StandardBrownianNode* node, int s);
00245 
00248 Real L(int j, StandardBrownianNode* node, int s);
00249 
00250 
00254 Real H_pq(int p, int q, StandardBrownianNode* node, int s);
00255 
00256 
00259 Real swapRate(int p, int q, StandardBrownianNode* node, int s);
00260                 
00261 
00266 Real forwardSwaptionPayoff(int p, int q, Real kappa, StandardBrownianNode* node, int s);
00267 
00268 
00273 Real forwardCapletPayoff(int i, Real kappa, StandardBrownianNode* node, int s);
00274 
00275 
00278 Real forwardBondCallPayoff(BondCall* bc, StandardBrownianNode* node, int s);
00279 
00280                         
00281 private:
00282         
00283 // build lattice with m time steps.
00284 void buildLattice(int m, bool verbose);
00285 
00286 // continuous time reached after time step s=0,1,...
00287 Real tau(int s);
00288 
00289         static RealArray1D H_;     // workspace for accrual factors H_j
00290         static RealArray1D V_;     // workspace for volatility parts V_j of the log(U_j)
00291                                    // book, 8.1 
00292 
00293                 
00294 }; // end LmmLattice
00295 
00296 
00297 
00298 
00299 
00300 MTGL_END_NAMESPACE(Martingale)
00301 
00302 #endif
00303  

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