1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2009 Dimitri Reiswich 5 6 This file is part of QuantLib, a free-software/open-source library 7 for financial quantitative analysts and developers - http://quantlib.org/ 8 9 QuantLib is free software: you can redistribute it and/or modify it 10 under the terms of the QuantLib license. You should have received a 11 copy of the license along with this program; if not, please email 12 <quantlib-dev@lists.sf.net>. The license is also available online at 13 <http://quantlib.org/license.shtml>. 14 15 This program is distributed in the hope that it will be useful, but WITHOUT 16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 17 FOR A PARTICULAR PURPOSE. See the license for more details. 18 */ 19 20 /*! \file analyticcompoundoptionengine.hpp 21 \brief Analytic compound option engines 22 */ 23 24 #ifndef quantlib_analytic_compound_option_engine_hpp 25 #define quantlib_analytic_compound_option_engine_hpp 26 27 #include <ql/experimental/exoticoptions/compoundoption.hpp> 28 #include <ql/processes/blackscholesprocess.hpp> 29 #include <ql/math/distributions/bivariatenormaldistribution.hpp> 30 31 namespace QuantLib { 32 33 //! Pricing engine for compound options using analytical formulae 34 /*! The formulas are taken from "Foreign Exchange Risk", 35 Uwe Wystup, Risk 2002, where closed form Greeks are available. 36 (not available in Haug 2007). 37 Value: Page 84, Greeks: Pages 94-95. 38 39 \test the correctness of the returned value is tested by 40 reproducing results available in literature. 41 */ 42 class AnalyticCompoundOptionEngine : public CompoundOption::engine { 43 public: 44 explicit AnalyticCompoundOptionEngine( 45 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process); 46 void calculate() const; 47 48 private: 49 CumulativeNormalDistribution N_; 50 NormalDistribution n_; 51 ext::shared_ptr<GeneralizedBlackScholesProcess> process_; 52 53 // helper methods 54 Time residualTimeMother() const; 55 Time residualTimeDaughter() const; 56 Time residualTimeMotherDaughter() const; 57 58 Date maturityMother() const; 59 Date maturityDaughter() const; 60 61 Real dPlus() const; 62 Real dMinus() const; 63 64 Real dPlusTau12(Real S) const; 65 Real dMinusTau12() const; 66 67 Real strikeDaughter() const; 68 Real strikeMother() const; 69 70 Real spot() const; 71 72 Real volatilityDaughter() const; 73 Real volatilityMother() const; 74 75 Real riskFreeRateDaughter() const; 76 Real dividendRateDaughter() const; 77 78 Real stdDeviationDaughter() const; 79 Real stdDeviationMother() const; 80 81 Real typeDaughter() const; 82 Real typeMother() const; 83 84 Real transformX(Real X) const; 85 Real e(Real X) const; 86 87 DiscountFactor riskFreeDiscountDaughter() const; 88 DiscountFactor riskFreeDiscountMother() const; 89 DiscountFactor riskFreeDiscountMotherDaughter() const; 90 91 DiscountFactor dividendDiscountDaughter() const; 92 DiscountFactor dividendDiscountMother() const; 93 DiscountFactor dividendDiscountMotherDaughter() const; 94 95 ext::shared_ptr<PlainVanillaPayoff> payoffMother() const; 96 ext::shared_ptr<PlainVanillaPayoff> payoffDaughter() const; 97 }; 98 99 } 100 101 #endif 102