/src/quantlib/ql/instruments/partialtimebarrieroption.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2014 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 | | <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/partialtimebarrieroption.hpp> |
21 | | #include <ql/exercise.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | | PartialTimeBarrierOption::PartialTimeBarrierOption( |
26 | | Barrier::Type barrierType, |
27 | | PartialBarrier::Range barrierRange, |
28 | | Real barrier, |
29 | | Real rebate, |
30 | | Date coverEventDate, |
31 | | const ext::shared_ptr<StrikedTypePayoff>& payoff, |
32 | | const ext::shared_ptr<Exercise>& exercise) |
33 | 0 | : OneAssetOption(payoff, exercise), |
34 | 0 | barrierType_(barrierType), barrierRange_(barrierRange), |
35 | 0 | barrier_(barrier), rebate_(rebate), |
36 | 0 | coverEventDate_(coverEventDate) {}Unexecuted instantiation: QuantLib::PartialTimeBarrierOption::PartialTimeBarrierOption(QuantLib::Barrier::Type, QuantLib::PartialBarrier::Range, double, double, QuantLib::Date, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&) Unexecuted instantiation: QuantLib::PartialTimeBarrierOption::PartialTimeBarrierOption(QuantLib::Barrier::Type, QuantLib::PartialBarrier::Range, double, double, QuantLib::Date, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&) |
37 | | |
38 | | void PartialTimeBarrierOption::setupArguments( |
39 | 0 | PricingEngine::arguments* args) const { |
40 | 0 | OneAssetOption::setupArguments(args); |
41 | |
|
42 | 0 | auto* moreArgs = dynamic_cast<PartialTimeBarrierOption::arguments*>(args); |
43 | 0 | QL_REQUIRE(moreArgs != nullptr, "wrong argument type"); |
44 | 0 | moreArgs->barrierType = barrierType_; |
45 | 0 | moreArgs->barrierRange = barrierRange_; |
46 | 0 | moreArgs->barrier = barrier_; |
47 | 0 | moreArgs->rebate = rebate_; |
48 | 0 | moreArgs->coverEventDate = coverEventDate_; |
49 | 0 | } |
50 | | |
51 | | PartialTimeBarrierOption::arguments::arguments() |
52 | 0 | : barrierType(Barrier::Type(-1)), |
53 | 0 | barrierRange(PartialBarrier::Range(-1)), |
54 | 0 | barrier(Null<Real>()), rebate(Null<Real>()) {}Unexecuted instantiation: QuantLib::PartialTimeBarrierOption::arguments::arguments() Unexecuted instantiation: QuantLib::PartialTimeBarrierOption::arguments::arguments() |
55 | | |
56 | 0 | void PartialTimeBarrierOption::arguments::validate() const { |
57 | 0 | OneAssetOption::arguments::validate(); |
58 | |
|
59 | 0 | QL_REQUIRE(barrier != Null<Real>(), "no barrier given"); |
60 | 0 | QL_REQUIRE(rebate != Null<Real>(), "no rebate given"); |
61 | 0 | QL_REQUIRE(coverEventDate != Date(), "no cover event date given"); |
62 | 0 | QL_REQUIRE(coverEventDate < exercise->lastDate(), |
63 | 0 | "cover event date equal or later than exercise date"); |
64 | 0 | } |
65 | | |
66 | | } |