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

Option.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 /*
00025  * Derivatives.h
00026  *
00027  * Created on March 21, 2003, 12:45 PM
00028  */
00029  
00030  
00031 #ifndef martingale_option_h    
00032 #define martingale_option_h
00033 
00034 #include "TypedefsMacros.h"
00035 #include "Pricing.h"                   // needed in template function
00036 #include "Node.h"                      // problem with template forward declarations
00037 #include <cstdlib>                     // exit(int)
00038 
00039 
00040 
00041 
00042 MTGL_BEGIN_NAMESPACE(Martingale)
00043 
00044 
00045 // dependencies
00046 class LiborMarketModel;
00047 class Bond;
00048 // class RealVector;
00049 class StandardBrownianNode;
00050 class LmmLattice; 
00051 
00052 
00053 
00054 
00065 /*******************************************************************************
00066  *
00067  *                     Option
00068  *
00069  ******************************************************************************/
00070 
00080 class Option {
00081         
00082 protected:
00083     
00084          Real T_;                 // time to expiry in years
00085          bool hasAnalytic_,       // analytic pricing formula implemented
00086               hasLattice_,        // evaluation in lattice implemented
00087               hasMonteCarlo_,     // Monte Carlo path pricing implemented
00088               hasControlVariate_; // control variate is implemented
00089        
00090 
00091 public:                                                          
00092         
00094         Real getExpiration(){ return T_; }
00095 
00102     Option(Real T, bool an, bool lt, bool mc, bool cv) : 
00103         T_(T), 
00104         hasAnalytic_(an), hasLattice_(lt), hasMonteCarlo_(mc), hasControlVariate_(cv)
00105         {   }
00106         
00107         
00108 // PAYOFF
00109 
00112 virtual bool isExercisable(Real t){ return false; }     
00113                     
00115 virtual Real nextForwardPayoff(){ return -1.0; }
00116          
00118 virtual Real controlVariateMean(){ return 0.0; }
00119          
00124 virtual const RealArray1D nextControlledForwardPayoff();
00125 
00130 template<typename LatticeType, int t>
00131 Real forwardPayoff
00132 (typename LatticeType::NodeType* node, LatticeType* theLattice, int t){ return -1.0; }
00133         
00134          
00138 virtual Real analyticForwardPrice() const;
00139         
00141 Real monteCarloForwardPrice(int N);
00142 
00146 Real controlledMonteCarloForwardPrice(int nPaths);
00147 
00151 Real correlationWithControlVariate(int N);
00152 
00157 virtual Real latticeForwardPrice();
00158 
00160 virtual std::ostream& printSelf(std::ostream& os) const;
00161       
00162      
00163 }; // end Derivative
00164 
00165 
00166 
00167 
00168 
00169 
00170 /*******************************************************************************
00171  *
00172  *                          LIBOR DERIVATIVE
00173  *
00174  ******************************************************************************/        
00175 
00186 class LiborDerivative : public Option {
00187         
00188 protected:
00189         
00190         LiborMarketModel* LMM;     // the underlying LMM
00191         int n;                     // number of Libors including L_0
00192         int t;                     // Libors are needed until time T_t for option payoff
00193 
00194 public:
00195         
00203 // T_t is handed to Option as "time to expiration".
00204 LiborDerivative
00205 (LiborMarketModel* lmm, int s, bool an, bool lt, bool mc, bool cv);
00206 
00207 virtual ~LiborDerivative(){ }
00208         
00210 // Usually this is t but not always, see Caplet where it is t-1.
00211 virtual int getPeriodsToExpiry(){ return t; }
00212         
00214 int  getDimension() const { return n; }
00215         
00220 int effectiveDimension() const;
00221 
00222 
00233 LmmLattice* getDefaultLattice();
00234 
00235 
00239 virtual Real forwardPayoff(StandardBrownianNode* node, LmmLattice* theLattice, int s);
00240 
00241 
00243 Real latticeForwardPrice(LmmLattice* theLattice);
00244         
00245         
00249 Real latticeForwardPrice(){ return latticeForwardPrice(getDefaultLattice()); }
00250 
00251         
00253 std::ostream& printSelf(std::ostream& os) const;
00254         
00255 
00256 // TESTING PRICING ROUTINES
00257 
00265 virtual void testPrice(int nPath);
00266 
00267                 
00268 }; // end LiborDerivative
00269 
00270 
00271 
00272 
00273 /*******************************************************************************
00274  *
00275  *                          CAPLETS
00276  *
00277  ******************************************************************************/
00278 
00279 
00280 
00286 class Caplet : public LiborDerivative {
00287    
00288         int  i;                  // accrual interval [T_i,T_{i+1}]
00289     Real kappa,              // strike rate
00290              delta_i;            // T_{i+1}-T_i
00291         
00292 
00293              
00294 public: 
00295         
00297 int getPeriodsToExpiry(){ return i; }
00298 
00299 
00300 // CONSTRUCTOR
00301 
00309 Caplet(int j, Real strike, LiborMarketModel* lmm);
00310         
00311 
00320 static Caplet* sample
00321 (int n, 
00322  int lmmType = 0,    // LiborMarketModel::DL, we use literals to avoid includes 
00323  int volType = 2,    // VolSurface::CONST
00324  int corrType =1     // Correlations::CS
00325 );
00326                 
00327 
00328 // PAYOFF
00329 
00333 Real nextForwardPayoff();
00334 
00337 Real controlVariateMean();
00338 
00341 const RealArray1D nextControlledForwardPayoff();
00342 
00350 Real forwardPayoff(StandardBrownianNode* node, LmmLattice* theLattice, int s);
00351 
00352 
00353 
00354 // Payoffs at nodes not implemented. Delay problem: payoff determined at time T_i
00355 // but received at time T_{i+1}. So forward transporting involves (one step)
00356 // path history. Not amenable to lattice treatment.
00357       
00358 // ANALYTIC PRICE
00359 
00360          
00363 Real analyticForwardPrice() const;
00364    
00365 
00366    
00367 // PRINTING
00368 
00370 std::ostream& printSelf(std::ostream& os) const;
00371 
00372 
00373 }; // end Caplet
00374 
00375 
00376 
00377 
00378 
00379 
00380 /*******************************************************************************
00381  *
00382  *                          SWAPTIONS
00383  *
00384  ******************************************************************************/
00385 
00386 
00393 class Swaption : public LiborDerivative {
00394    
00395         int  p,q,                // swap period [T_p,T_q]       
00396              t;                  // swaption exercises at T_t
00397     Real kappa;              // strike rate
00398         
00399              
00400 public:
00401 
00402 
00403 // CONSTRUCTOR
00404 
00413 Swaption(int p, int q, int t, Real strike, LiborMarketModel* lmm);
00414         
00415 
00423 static Swaption* sample
00424 (int p, int q,
00425  int lmmType = 0,    // LiborMarketModel::DL, we use literals to avoid includes 
00426  int volType = 2,    // VolSurface::CONST
00427  int corrType =1     // Correlations::CS
00428 );
00429         
00430          
00431     
00432 // FORWARD TRANSPORTED PAYOFF AND CONTROL VARIATE
00433 
00437 Real nextForwardPayoff();
00438 
00441 Real controlVariateMean();
00442 
00445 const RealArray1D nextControlledForwardPayoff();
00446 
00447 
00453 Real forwardPayoff(StandardBrownianNode* node, LmmLattice* theLattice, int s);
00454 
00455 
00456 // PRICING
00457          
00459 Real analyticForwardPrice() const;
00460    
00462 std::ostream& printSelf(std::ostream& os) const;
00463 
00464 }; // end swaption
00465 
00466 
00467 
00468 
00469 /*******************************************************************************
00470  *
00471  *                   CALL ON BONDS
00472  *
00473  ******************************************************************************/
00474 
00475 
00480 class BondCall : public LiborDerivative {
00481    
00482         Bond* B;                 // the underlying bond
00483         int p,q;                 // coupon periods [T_p,T_q]
00484 
00485         Real K;                  // strike rate
00486         int t;                   // call exercises at time T_t
00487 
00488              
00489 public:
00490 
00491         
00493 Bond* getBond(){ return B; }
00494 
00496 Real getStrike(){ return K; }
00497 
00504 BondCall(Bond* D, Real strike, int s);
00505                 
00516 static BondCall* sample
00517 (int p, int q, 
00518  int lmmType = 0,    // LiborMarketModel::DL, we use literals to avoid includes 
00519  int volType = 2,    // VolSurface::CONST
00520  int corrType =1     // Correlations::CS
00521 );
00522         
00523          
00534 static BondCall* sampleCallOnZeroCouponBond
00535 (int p, 
00536  int lmmType = 0,    // LiborMarketModel::DL, we use literals to avoid includes 
00537  int volType = 2,    // VolSurface::CONST
00538  int corrType =1     // Correlations::CS
00539 );
00540 
00541         
00542 // FORWARD TRANSPORTED PAYOFF AND CONTROL VARIATE
00543 
00547 Real nextForwardPayoff();
00548 
00551 Real controlVariateMean();
00552 
00555 const RealArray1D nextControlledForwardPayoff();
00556 
00562 Real forwardPayoff(StandardBrownianNode* node, LmmLattice* theLattice, int s);
00563    
00565 Real analyticForwardPrice() const;
00566    
00568 std::ostream& printSelf(std::ostream& os) const;
00569 
00570    
00571 }; // end BondCall
00572 
00573 
00574 
00575 
00576 
00577 MTGL_END_NAMESPACE(Martingale)
00578 
00579 #endif

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