/src/quantlib/ql/instruments/quantobarrieroption.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 Paul Farrington |
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 | | <https://www.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 | | #include <ql/instruments/quantobarrieroption.hpp> |
21 | | |
22 | | namespace QuantLib { |
23 | | |
24 | | QuantoBarrierOption::QuantoBarrierOption( |
25 | | Barrier::Type barrierType, |
26 | | Real barrier, |
27 | | Real rebate, |
28 | | const ext::shared_ptr<StrikedTypePayoff>& payoff, |
29 | | const ext::shared_ptr<Exercise>& exercise) |
30 | 0 | : BarrierOption(barrierType, barrier, rebate, payoff, exercise) {}Unexecuted instantiation: QuantLib::QuantoBarrierOption::QuantoBarrierOption(QuantLib::Barrier::Type, double, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&) Unexecuted instantiation: QuantLib::QuantoBarrierOption::QuantoBarrierOption(QuantLib::Barrier::Type, double, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&) |
31 | | |
32 | 0 | Real QuantoBarrierOption::qvega() const { |
33 | 0 | calculate(); |
34 | 0 | QL_REQUIRE(qvega_ != Null<Real>(), |
35 | 0 | "exchange rate vega calculation failed"); |
36 | 0 | return qvega_; |
37 | 0 | } |
38 | | |
39 | 0 | Real QuantoBarrierOption::qrho() const { |
40 | 0 | calculate(); |
41 | 0 | QL_REQUIRE(qrho_ != Null<Real>(), |
42 | 0 | "foreign interest rate rho calculation failed"); |
43 | 0 | return qrho_; |
44 | 0 | } |
45 | | |
46 | 0 | Real QuantoBarrierOption::qlambda() const { |
47 | 0 | calculate(); |
48 | 0 | QL_REQUIRE(qlambda_ != Null<Real>(), |
49 | 0 | "quanto correlation sensitivity calculation failed"); |
50 | 0 | return qlambda_; |
51 | 0 | } |
52 | | |
53 | 0 | void QuantoBarrierOption::setupExpired() const { |
54 | 0 | BarrierOption::setupExpired(); |
55 | 0 | qvega_ = qrho_ = qlambda_ = 0.0; |
56 | 0 | } |
57 | | |
58 | | void QuantoBarrierOption::fetchResults( |
59 | 0 | const PricingEngine::results* r) const { |
60 | 0 | BarrierOption::fetchResults(r); |
61 | 0 | const auto* quantoResults = dynamic_cast<const QuantoBarrierOption::results*>(r); |
62 | 0 | QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine"); |
63 | 0 | qrho_ = quantoResults->qrho; |
64 | 0 | qvega_ = quantoResults->qvega; |
65 | 0 | qlambda_ = quantoResults->qlambda; |
66 | 0 | } |
67 | | |
68 | | } |
69 | | |