Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cdsoption.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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/*
20 Copyright (C) 2008 Roland Stamm
21 Copyright (C) 2009 Jose Aparicio
22
23 This file is part of QuantLib, a free-software/open-source library
24 for financial quantitative analysts and developers - http://quantlib.org/
25
26 QuantLib is free software: you can redistribute it and/or modify it
27 under the terms of the QuantLib license. You should have received a
28 copy of the license along with this program; if not, please email
29 <quantlib-dev@lists.sf.net>. The license is also available online at
30 <http://quantlib.org/license.shtml>.
31
32 This program is distributed in the hope that it will be useful, but WITHOUT
33 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
34 FOR A PARTICULAR PURPOSE. See the license for more details.
35*/
36
37/*! \file cdsoption.hpp
38 \brief CDS option, removed requirements (rec must knock out,
39 no upfront amount), that should be taken care of in pricing engines
40 \ingroup instruments
41*/
42
43#ifndef quantext_cds_option_hpp
44#define quantext_cds_option_hpp
45
46#include <ql/instruments/creditdefaultswap.hpp>
47
48#include <ql/option.hpp>
49
50namespace QuantLib {
51class Quote;
52class YieldTermStructure;
53} // namespace QuantLib
54
55namespace QuantExt {
56using namespace QuantLib;
57
58//! CDS option
59/*! The side of the swaption is set by choosing the side of the CDS.
60 A receiver CDS option is a right to buy an underlying CDS
61 selling protection and receiving a coupon. A payer CDS option
62 is a right to buy an underlying CDS buying protection and
63 paying coupon.
64
65 \ingroup instruments
66*/
67class CdsOption : public Option {
68public:
69 class arguments;
70 class results;
71 class engine;
72
74
75 CdsOption(const QuantLib::ext::shared_ptr<CreditDefaultSwap>& swap, const QuantLib::ext::shared_ptr<Exercise>& exercise,
76 bool knocksOut = true, const Real strike = Null<Real>(),
77 const StrikeType strikeType = StrikeType::Spread);
78
79 //! \name Instrument interface
80 //@{
81 bool isExpired() const override;
82 void setupArguments(PricingEngine::arguments*) const override;
83 //@}
84 //! \name Inspectors
85 //@{
86 const QuantLib::ext::shared_ptr<CreditDefaultSwap>& underlyingSwap() const { return swap_; }
87 //@}
88 //! \name Calculations
89 //@{
90 Rate atmRate() const;
91 Real riskyAnnuity() const;
92 Volatility impliedVolatility(Real price, const Handle<QuantLib::YieldTermStructure>& termStructure,
93 const Handle<DefaultProbabilityTermStructure>&, Real recoveryRate,
94 Real accuracy = 1.e-4, Size maxEvaluations = 100, Volatility minVol = 1.0e-7,
95 Volatility maxVol = 4.0) const;
96 //@}
97
98private:
99 QuantLib::ext::shared_ptr<CreditDefaultSwap> swap_;
103
104 mutable Real riskyAnnuity_;
105 void setupExpired() const override;
106 void fetchResults(const PricingEngine::results*) const override;
107};
108
109//! %Arguments for CDS-option calculation
110class CdsOption::arguments : public CreditDefaultSwap::arguments, public Option::arguments {
111public:
113
114 QuantLib::ext::shared_ptr<CreditDefaultSwap> swap;
116 Real strike;
118 void validate() const override;
119};
120
121//! %Results from CDS-option calculation
122//! \ingroup instruments
123class CdsOption::results : public Option::results {
124public:
126 void reset() override;
127};
128
129//! base class for swaption engines
130class CdsOption::engine : public GenericEngine<CdsOption::arguments, CdsOption::results> {};
131} // namespace QuantExt
132
133#endif
Arguments for CDS-option calculation
Definition: cdsoption.hpp:110
QuantLib::ext::shared_ptr< CreditDefaultSwap > swap
Definition: cdsoption.hpp:114
void validate() const override
Definition: cdsoption.cpp:143
base class for swaption engines
Definition: cdsoption.hpp:130
Real riskyAnnuity() const
Definition: cdsoption.cpp:122
void setupArguments(PricingEngine::arguments *) const override
Definition: cdsoption.cpp:99
Volatility impliedVolatility(Real price, const Handle< QuantLib::YieldTermStructure > &termStructure, const Handle< DefaultProbabilityTermStructure > &, Real recoveryRate, Real accuracy=1.e-4, Size maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0) const
Definition: cdsoption.cpp:128
bool isExpired() const override
Definition: cdsoption.cpp:92
QuantLib::ext::shared_ptr< CreditDefaultSwap > swap_
Definition: cdsoption.hpp:99
StrikeType strikeType_
Definition: cdsoption.hpp:102
Rate atmRate() const
Definition: cdsoption.cpp:120
void setupExpired() const override
Definition: cdsoption.cpp:94
const QuantLib::ext::shared_ptr< CreditDefaultSwap > & underlyingSwap() const
Definition: cdsoption.hpp:86
void fetchResults(const PricingEngine::results *) const override
Definition: cdsoption.cpp:113