00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef martingale_lmmlattice_h
00024 #define martingale_lmmlattice_h
00025
00026
00027 #include "TypedefsMacros.h"
00028 #include "Lattice.h"
00029 #include "Node.h"
00030 #include "Utils.h"
00031 #include "Array.h"
00032 #include "Matrix.h"
00033 #include "LiborFactorLoading.h"
00034 #include "Node.h"
00035
00036
00037 class std::ostream;
00038
00039
00040
00041 MTGL_BEGIN_NAMESPACE(Martingale)
00042
00043
00044
00045 class BondCall;
00046
00047
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00133 class LmmLattice : public Lattice<StandardBrownianNode> {
00134
00135 protected:
00136
00137
00138 LiborFactorLoading* factorLoading;
00139
00140 int n,
00141 r,
00142 nSteps;
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
00187
00195 LmmLattice(int q, LiborFactorLoading* fl, int t, int steps=1, bool verbose=false);
00196
00197 virtual ~LmmLattice(){ }
00198
00199
00200
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
00232
00241
00242
00243
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
00284 void buildLattice(int m, bool verbose);
00285
00286
00287 Real tau(int s);
00288
00289 static RealArray1D H_;
00290 static RealArray1D V_;
00291
00292
00293
00294 };
00295
00296
00297
00298
00299
00300 MTGL_END_NAMESPACE(Martingale)
00301
00302 #endif
00303