/src/quantlib/ql/experimental/mcbasket/pathmultiassetoption.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2008 Andrea Odetti |
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/experimental/mcbasket/pathmultiassetoption.hpp> |
21 | | #include <ql/processes/stochasticprocessarray.hpp> |
22 | | #include <ql/termstructures/volatility/equityfx/blackconstantvol.hpp> |
23 | | #include <ql/math/solvers1d/brent.hpp> |
24 | | #include <ql/event.hpp> |
25 | | |
26 | | namespace QuantLib { |
27 | | |
28 | | PathMultiAssetOption::PathMultiAssetOption( |
29 | 0 | const ext::shared_ptr<PricingEngine>& engine) { |
30 | 0 | if (engine != nullptr) |
31 | 0 | setPricingEngine(engine); |
32 | 0 | } |
33 | | |
34 | 0 | bool PathMultiAssetOption::isExpired() const { |
35 | 0 | return detail::simple_event(fixingDates().back()).hasOccurred(); |
36 | 0 | } |
37 | | |
38 | 0 | void PathMultiAssetOption::setupExpired() const { |
39 | 0 | NPV_ = 0.0; |
40 | 0 | } |
41 | | |
42 | | void PathMultiAssetOption::setupArguments(PricingEngine::arguments* args) |
43 | 0 | const { |
44 | 0 | auto* arguments = dynamic_cast<PathMultiAssetOption::arguments*>(args); |
45 | |
|
46 | 0 | QL_REQUIRE(arguments != nullptr, "wrong argument type"); |
47 | | |
48 | 0 | arguments->payoff = pathPayoff(); |
49 | 0 | arguments->fixingDates = fixingDates(); |
50 | 0 | } |
51 | | |
52 | 0 | void PathMultiAssetOption::arguments::validate() const { |
53 | 0 | QL_REQUIRE(payoff, "no payoff given"); |
54 | 0 | QL_REQUIRE(!fixingDates.empty(), "no dates given"); |
55 | 0 | } |
56 | | } |
57 | | |