/src/quantlib/ql/experimental/exoticoptions/everestoption.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 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 | | #include <ql/experimental/exoticoptions/everestoption.hpp> |
21 | | #include <ql/instruments/payoffs.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | | EverestOption::EverestOption(Real notional, |
26 | | Rate guarantee, |
27 | | const ext::shared_ptr<Exercise>& exercise) |
28 | 0 | : MultiAssetOption(ext::shared_ptr<Payoff>(new NullPayoff), exercise), |
29 | 0 | notional_(notional), guarantee_(guarantee) {} Unexecuted instantiation: QuantLib::EverestOption::EverestOption(double, double, boost::shared_ptr<QuantLib::Exercise> const&) Unexecuted instantiation: QuantLib::EverestOption::EverestOption(double, double, boost::shared_ptr<QuantLib::Exercise> const&) |
30 | | |
31 | 0 | Rate EverestOption::yield() const { |
32 | 0 | calculate(); |
33 | 0 | QL_REQUIRE(yield_ != Null<Rate>(), "yield not provided"); |
34 | 0 | return yield_; |
35 | 0 | } |
36 | | |
37 | 0 | void EverestOption::setupArguments(PricingEngine::arguments* args) const { |
38 | 0 | MultiAssetOption::setupArguments(args); |
39 | |
|
40 | 0 | auto* arguments = dynamic_cast<EverestOption::arguments*>(args); |
41 | 0 | QL_REQUIRE(arguments != nullptr, "wrong argument type"); |
42 | | |
43 | 0 | arguments->notional = notional_; |
44 | 0 | arguments->guarantee= guarantee_; |
45 | 0 | } |
46 | | |
47 | 0 | void EverestOption::fetchResults(const PricingEngine::results* r) const { |
48 | 0 | MultiAssetOption::fetchResults(r); |
49 | 0 | const auto* results = dynamic_cast<const EverestOption::results*>(r); |
50 | 0 | QL_ENSURE(results != nullptr, "no results returned from pricing engine"); |
51 | 0 | yield_ = results->yield; |
52 | 0 | } |
53 | | |
54 | | |
55 | | EverestOption::arguments::arguments() |
56 | 0 | : notional(Null<Real>()), guarantee(Null<Rate>()) {} Unexecuted instantiation: QuantLib::EverestOption::arguments::arguments() Unexecuted instantiation: QuantLib::EverestOption::arguments::arguments() |
57 | | |
58 | 0 | void EverestOption::arguments::validate() const { |
59 | 0 | MultiAssetOption::arguments::validate(); |
60 | 0 | QL_REQUIRE(notional != Null<Rate>(), "no notional given"); |
61 | 0 | QL_REQUIRE(notional != 0.0, "null notional given"); |
62 | 0 | QL_REQUIRE(guarantee != Null<Rate>(), "no guarantee given"); |
63 | 0 | } |
64 | | |
65 | | |
66 | 0 | void EverestOption::results::reset() { |
67 | 0 | MultiAssetOption::results::reset(); |
68 | 0 | yield = Null<Rate>(); |
69 | 0 | } |
70 | | |
71 | | } |
72 | | |