Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
genericswaption.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Manaement Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21#include <ql/exercise.hpp>
22#include <ql/shared_ptr.hpp>
23
24namespace QuantExt {
25
26GenericSwaption::GenericSwaption(const ext::shared_ptr<QuantLib::Swap>& swap, const ext::shared_ptr<Exercise>& exercise,
27 Settlement::Type delivery, Settlement::Method settlementMethod)
28 : Option(ext::shared_ptr<Payoff>(), exercise), swap_(swap), settlementType_(delivery),
29 settlementMethod_(settlementMethod) {
30 registerWith(swap_);
31 swap_->alwaysForwardNotifications();
32}
33
34bool GenericSwaption::isExpired() const { return detail::simple_event(exercise_->dates().back()).hasOccurred(); }
35
36void GenericSwaption::setupArguments(PricingEngine::arguments* args) const {
37 swap_->setupArguments(args);
38 Option::setupArguments(args);
39
41
42 QL_REQUIRE(arguments != 0, "wrong argument type");
43
47 arguments->exercise = exercise_;
48}
49
50void GenericSwaption::fetchResults(const PricingEngine::results* r) const {
51 Option::fetchResults(r);
52 const GenericSwaption::results* results = dynamic_cast<const GenericSwaption::results*>(r);
53 QL_ENSURE(results != 0, "wrong results type");
55}
56
58 Option::results::reset();
59 underlyingValue = Null<Real>();
60}
61
63 Swap::arguments::validate();
64 QL_REQUIRE(swap, "underlying swap not set");
65 QL_REQUIRE(exercise, "exercise not set");
66 QuantLib::Settlement::checkTypeAndMethodConsistency(settlementType, settlementMethod);
67}
68
69} // namespace QuantExt
Arguments for swaption calculation
ext::shared_ptr< QuantLib::Swap > swap
QuantLib::Settlement::Type settlementType
QuantLib::Settlement::Method settlementMethod
Results from CDS-option calculation
ext::shared_ptr< QuantLib::Swap > swap_
QuantLib::Settlement::Type settlementType_
void setupArguments(PricingEngine::arguments *) const override
Settlement::Type settlementType() const
bool isExpired() const override
QuantLib::Settlement::Method settlementMethod_
GenericSwaption(const ext::shared_ptr< QuantLib::Swap > &swap, const ext::shared_ptr< Exercise > &exercise, QuantLib::Settlement::Type delivery=QuantLib::Settlement::Physical, QuantLib::Settlement::Method settlementMethod=QuantLib::Settlement::PhysicalOTC)
void fetchResults(const PricingEngine::results *) const override
Settlement::Method settlementMethod() const
Swaption class.