| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2002, 2003 Ferdinando Ametrano |
| 5 | Copyright (C) 2007 StatPro Italia srl |
| 6 | |
| 7 | This file is part of QuantLib, a free-software/open-source library |
| 8 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 9 | |
| 10 | QuantLib is free software: you can redistribute it and/or modify it |
| 11 | under the terms of the QuantLib license. You should have received a |
| 12 | copy of the license along with this program; if not, please email |
| 13 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 14 | <http://quantlib.org/license.shtml>. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 17 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 18 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 19 | */ |
| 20 | |
| 21 | /*! \file quantovanillaoption.hpp |
| 22 | \brief Quanto version of a vanilla option |
| 23 | */ |
| 24 | |
| 25 | #ifndef quantlib_quanto_vanilla_option_hpp |
| 26 | #define quantlib_quanto_vanilla_option_hpp |
| 27 | |
| 28 | #include <ql/instruments/oneassetoption.hpp> |
| 29 | #include <ql/instruments/payoffs.hpp> |
| 30 | |
| 31 | namespace QuantLib { |
| 32 | |
| 33 | //! %Results from quanto option calculation |
| 34 | template<class ResultsType> |
| 35 | class QuantoOptionResults : public ResultsType { |
| 36 | public: |
| 37 | QuantoOptionResults() { reset() ;} |
| 38 | void reset() override { |
| 39 | ResultsType::reset(); |
| 40 | qvega = qrho = qlambda = Null<Real>(); |
| 41 | } |
| 42 | Real qvega; |
| 43 | Real qrho; |
| 44 | Real qlambda; |
| 45 | }; |
| 46 | |
| 47 | //! quanto version of a vanilla option |
| 48 | /*! \ingroup instruments */ |
| 49 | class QuantoVanillaOption : public OneAssetOption { |
| 50 | public: |
| 51 | typedef OneAssetOption::arguments arguments; |
| 52 | typedef QuantoOptionResults<OneAssetOption::results> results; |
| 53 | typedef GenericEngine<arguments, results> engine; |
| 54 | QuantoVanillaOption(const ext::shared_ptr<StrikedTypePayoff>&, |
| 55 | const ext::shared_ptr<Exercise>&); |
| 56 | //! \name greeks |
| 57 | //@{ |
| 58 | Real qvega() const; |
| 59 | Real qrho() const; |
| 60 | Real qlambda() const; |
| 61 | //@} |
| 62 | void fetchResults(const PricingEngine::results*) const override; |
| 63 | |
| 64 | private: |
| 65 | void setupExpired() const override; |
| 66 | // results |
| 67 | mutable Real qvega_, qrho_, qlambda_; |
| 68 | }; |
| 69 | |
| 70 | } |
| 71 | |
| 72 | |
| 73 | #endif |
| 74 | |