/src/quantlib/ql/models/equity/hestonmodelhelper.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2005 Klaus Spanderen |
5 | | Copyright (C) 2015 Peter Caspers |
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 | | <https://www.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 hestonmodelhelper.hpp |
22 | | \brief Heston-model calibration helper |
23 | | */ |
24 | | |
25 | | #ifndef quantlib_heston_option_helper_hpp |
26 | | #define quantlib_heston_option_helper_hpp |
27 | | |
28 | | #include <ql/models/calibrationhelper.hpp> |
29 | | #include <ql/instruments/vanillaoption.hpp> |
30 | | |
31 | | namespace QuantLib { |
32 | | |
33 | | //! calibration helper for Heston model |
34 | | class HestonModelHelper : public BlackCalibrationHelper { |
35 | | public: |
36 | | HestonModelHelper(const Period& maturity, |
37 | | Calendar calendar, |
38 | | Real s0, |
39 | | Real strikePrice, |
40 | | const Handle<Quote>& volatility, |
41 | | const Handle<YieldTermStructure>& riskFreeRate, |
42 | | const Handle<YieldTermStructure>& dividendYield, |
43 | | BlackCalibrationHelper::CalibrationErrorType errorType = |
44 | | BlackCalibrationHelper::RelativePriceError); |
45 | | |
46 | | HestonModelHelper(const Period& maturity, |
47 | | Calendar calendar, |
48 | | const Handle<Quote>& s0, |
49 | | Real strikePrice, |
50 | | const Handle<Quote>& volatility, |
51 | | const Handle<YieldTermStructure>& riskFreeRate, |
52 | | const Handle<YieldTermStructure>& dividendYield, |
53 | | BlackCalibrationHelper::CalibrationErrorType errorType = |
54 | | BlackCalibrationHelper::RelativePriceError); |
55 | | |
56 | 0 | void addTimesTo(std::list<Time>&) const override {} |
57 | | void performCalculations() const override; |
58 | | Real modelValue() const override; |
59 | | Real blackPrice(Real volatility) const override; |
60 | 0 | Time maturity() const { calculate(); return tau_; } |
61 | | private: |
62 | | const Period maturity_; |
63 | | const Calendar calendar_; |
64 | | const Handle<Quote> s0_; |
65 | | const Real strikePrice_; |
66 | | const Handle<YieldTermStructure> riskFreeRate_; |
67 | | const Handle<YieldTermStructure> dividendYield_; |
68 | | mutable Date exerciseDate_; |
69 | | mutable Time tau_; |
70 | | mutable Option::Type type_; |
71 | | mutable ext::shared_ptr<VanillaOption> option_; |
72 | | }; |
73 | | |
74 | | } |
75 | | |
76 | | |
77 | | #endif |
78 | | |