1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2012 Master IMAFA - Polytech'Nice Sophia - Université de Nice Sophia Antipolis 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 analytictwoassetbarrierengine.hpp 21 \brief Analytic engine for barrier option on two assets 22 */ 23 24 #ifndef quantlib_analytic_two_asset_barrier_engine_hpp 25 #define quantlib_analytic_two_asset_barrier_engine_hpp 26 27 #include <ql/experimental/exoticoptions/twoassetbarrieroption.hpp> 28 #include <ql/processes/blackscholesprocess.hpp> 29 30 namespace QuantLib { 31 32 //! Analytic engine for barrier option on two assets 33 /*! The formulas are taken from "Option pricing formulas", 34 E.G. Haug, McGraw-Hill, 35 36 \ingroup barrierengines 37 38 \test the correctness of the returned value is tested by 39 reproducing results available in literature. 40 */ 41 class AnalyticTwoAssetBarrierEngine 42 : public TwoAssetBarrierOption::engine { 43 public: 44 AnalyticTwoAssetBarrierEngine( 45 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process1, 46 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process2, 47 const Handle<Quote>& rho); 48 void calculate() const; 49 private: 50 ext::shared_ptr<GeneralizedBlackScholesProcess> process1_; 51 ext::shared_ptr<GeneralizedBlackScholesProcess> process2_; 52 Handle<Quote> rho_; 53 54 // helper methods 55 Real underlying1() const; 56 Real underlying2() const; 57 58 Real strike() const; 59 Time residualTime() const; 60 61 Volatility volatility1() const; 62 Volatility volatility2() const; 63 64 Real barrier() const; 65 Real rho() const; 66 67 Rate riskFreeRate() const; 68 69 Rate dividendYield1() const; 70 Rate dividendYield2() const; 71 72 Rate costOfCarry1() const; 73 Rate costOfCarry2() const; 74 75 Real mu(Real b, Real vol) const; 76 77 Real d1() const; 78 Real d2() const; 79 Real d3() const; 80 Real d4() const; 81 82 Real e1() const; 83 Real e2() const; 84 Real e3() const; 85 Real e4() const; 86 87 Real call() const; 88 Real put() const; 89 90 Real A(Real eta, Real phi) const; 91 Real B(Real eta, Real phi) const; 92 93 Real M(Real m_a, Real m_b,Real rho) const; 94 }; 95 96 } 97 98 99 #endif 100