1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 3 /* 4 Copyright (C) 2010 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 margrabeoption.hpp 21 \brief Margrabe option on two assets 22 */ 23 24 #ifndef quantlib_margrabe_option_hpp 25 #define quantlib_margrabe_option_hpp 26 27 #include <ql/instruments/multiassetoption.hpp> 28 29 namespace QuantLib { 30 31 //! Margrabe option on two assets 32 /*! This option gives the holder the right to exchange Q2 stocks 33 of the second asset for Q1 stocks of the first at expiration. 34 35 \ingroup instruments 36 */ 37 class MargrabeOption : public MultiAssetOption { 38 public: 39 class arguments; 40 class results; 41 class engine; 42 MargrabeOption(Integer Q1, 43 Integer Q2, 44 const ext::shared_ptr<Exercise>&); 45 void setupArguments(PricingEngine::arguments*) const; 46 Real delta1() const; 47 Real delta2() const; 48 Real gamma1() const; 49 Real gamma2() const; 50 void fetchResults(const PricingEngine::results*) const; 51 protected: 52 Integer Q1_; 53 Integer Q2_; 54 mutable Real delta1_, delta2_, gamma1_, gamma2_; 55 }; 56 57 //! Extra %arguments for Margrabe option 58 class MargrabeOption::arguments 59 : public MultiAssetOption::arguments { 60 public: arguments()61 arguments() : Q1(Null<Integer>()), 62 Q2(Null<Integer>()) {} 63 void validate() const; 64 Integer Q1; 65 Integer Q2; 66 }; 67 68 //! Extra %results for Margrabe option 69 class MargrabeOption::results 70 : public MultiAssetOption::results { 71 public: results()72 results() : delta1(Null<Real>()), 73 delta2(Null<Real>()), 74 gamma1(Null<Real>()), 75 gamma2(Null<Real>()) {} 76 Real delta1; 77 Real delta2; 78 Real gamma1; 79 Real gamma2; reset()80 void reset() { 81 MultiAssetOption::results::reset(); 82 delta1 = Null<Real>(); 83 delta2 = Null<Real>(); 84 gamma1 = Null<Real>(); 85 gamma2 = Null<Real>(); 86 } 87 }; 88 89 //! %Margrabe option %engine base class 90 class MargrabeOption::engine 91 : public GenericEngine<MargrabeOption::arguments, 92 MargrabeOption::results> {}; 93 } 94 95 96 #endif 97