QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cdsoption.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Roland Stamm
5 Copyright (C) 2009 Jose Aparicio
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_cds_option_hpp
26#define quantlib_cds_option_hpp
27
28#include <ql/option.hpp>
29#include <ql/instruments/creditdefaultswap.hpp>
30
31namespace QuantLib {
32
33 class Quote;
34 class YieldTermStructure;
35
37
43 class CdsOption : public Option {
44 public:
45 class arguments;
46 class results;
47 class engine;
48 CdsOption(const ext::shared_ptr<CreditDefaultSwap>& swap,
49 const ext::shared_ptr<Exercise>& exercise,
50 bool knocksOut = true);
51
53
54 bool isExpired() const override;
55 void setupArguments(PricingEngine::arguments*) const override;
57
59 const ext::shared_ptr<CreditDefaultSwap>& underlyingSwap() const {
60 return swap_;
61 }
63
65 Rate atmRate() const;
66 Real riskyAnnuity() const;
68 Real price,
69 const Handle<YieldTermStructure>& termStructure,
71 Real recoveryRate,
72 Real accuracy = 1.e-4,
73 Size maxEvaluations = 100,
74 Volatility minVol = 1.0e-7,
75 Volatility maxVol = 4.0) const;
77
78 private:
79 ext::shared_ptr<CreditDefaultSwap> swap_;
81
83 void setupExpired() const override;
84 void fetchResults(const PricingEngine::results*) const override;
85 };
86
87
90 public Option::arguments {
91 public:
92 arguments() = default;
93
94 ext::shared_ptr<CreditDefaultSwap> swap;
96 void validate() const override;
97 };
98
100 class CdsOption::results : public Option::results {
101 public:
103 void reset() override;
104 };
105
108 : public GenericEngine<CdsOption::arguments, CdsOption::results> {};
109
110}
111
112#endif
Arguments for CDS-option calculation
Definition: cdsoption.hpp:90
ext::shared_ptr< CreditDefaultSwap > swap
Definition: cdsoption.hpp:94
void validate() const override
Definition: cdsoption.cpp:143
base class for swaption engines
Definition: cdsoption.hpp:108
Results from CDS-option calculation
Definition: cdsoption.hpp:100
Real riskyAnnuity() const
Definition: cdsoption.cpp:114
void setupArguments(PricingEngine::arguments *) const override
Definition: cdsoption.cpp:89
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Definition: cdsoption.cpp:80
const ext::shared_ptr< CreditDefaultSwap > & underlyingSwap() const
Definition: cdsoption.hpp:59
Volatility impliedVolatility(Real price, const Handle< 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:120
Rate atmRate() const
Definition: cdsoption.cpp:110
void setupExpired() const override
Definition: cdsoption.cpp:84
void fetchResults(const PricingEngine::results *) const override
Definition: cdsoption.cpp:101
ext::shared_ptr< CreditDefaultSwap > swap_
Definition: cdsoption.hpp:79
template base class for option pricing engines
Shared handle to an observable.
Definition: handle.hpp:41
basic option arguments
Definition: option.hpp:57
base option class
Definition: option.hpp:36
ext::shared_ptr< Exercise > exercise() const
Definition: option.hpp:46
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
void swap(Array &v, Array &w) noexcept
Definition: array.hpp:903