Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
genericswaption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management 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
19/*! \file qle/instruments/genericswaption.hpp
20 \brief Swaption class
21*/
22
23#ifndef quantext_instruments_genericswaption_hpp
24#define quantext_instruments_genericswaption_hpp
25
26#include <ql/instruments/swap.hpp>
27#include <ql/instruments/swaption.hpp>
28#include <ql/option.hpp>
29#include <ql/termstructures/volatility/volatilitytype.hpp>
30#include <ql/termstructures/yieldtermstructure.hpp>
31
32namespace QuantExt {
33using namespace QuantLib;
34
35//! %Swaption class with QuantLib::Swap underlying
36/*! \ingroup instruments
37 */
38class GenericSwaption : public Option {
39public:
40 class arguments;
41 class results;
42 class engine;
43 GenericSwaption(const ext::shared_ptr<QuantLib::Swap>& swap, const ext::shared_ptr<Exercise>& exercise,
44 QuantLib::Settlement::Type delivery = QuantLib::Settlement::Physical,
45 QuantLib::Settlement::Method settlementMethod = QuantLib::Settlement::PhysicalOTC);
46 //! \name Instrument interface
47 //@{
48 bool isExpired() const override;
49 void setupArguments(PricingEngine::arguments*) const override;
50 //@}
51 //! \name Inspectors
52 //@{
53 Settlement::Type settlementType() const { return settlementType_; }
54 Settlement::Method settlementMethod() const { return settlementMethod_; }
55 const ext::shared_ptr<QuantLib::Swap>& underlyingSwap() const { return swap_; }
56 Real underlyingValue() const { return underlyingValue_; }
57 //@}
58private:
59 void fetchResults(const PricingEngine::results*) const override;
60 // arguments
61 ext::shared_ptr<QuantLib::Swap> swap_;
62 QuantLib::Settlement::Type settlementType_;
63 QuantLib::Settlement::Method settlementMethod_;
64 mutable Real underlyingValue_;
65};
66
67//! %Arguments for swaption calculation
68class GenericSwaption::arguments : public QuantLib::Swap::arguments, public Option::arguments {
69public:
70 arguments() : settlementType(Settlement::Physical) {}
71 ext::shared_ptr<QuantLib::Swap> swap;
72 QuantLib::Settlement::Type settlementType;
73 QuantLib::Settlement::Method settlementMethod;
74 void validate() const override;
75};
76
77//! %Results from CDS-option calculation
78class GenericSwaption::results : public Option::results {
79public:
81 void reset() override;
82};
83
84//! base class for swaption engines
85class GenericSwaption::engine : public GenericEngine<GenericSwaption::arguments, GenericSwaption::results> {};
86
87} // namespace QuantExt
88
89#endif
Arguments for swaption calculation
ext::shared_ptr< QuantLib::Swap > swap
QuantLib::Settlement::Type settlementType
QuantLib::Settlement::Method settlementMethod
base class for swaption engines
Results from CDS-option calculation
Swaption class with QuantLib::Swap underlying
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_
const ext::shared_ptr< QuantLib::Swap > & underlyingSwap() const
void fetchResults(const PricingEngine::results *) const override
Settlement::Method settlementMethod() const