Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
indexcdsoption.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/*! \file qle/instruments/indexcdsoption.hpp
20 \brief Index CDS option instrument
21*/
22
23#ifndef quantext_index_cds_option_hpp
24#define quantext_index_cds_option_hpp
25
28
29#include <ql/instruments/swaption.hpp>
30#include <ql/option.hpp>
31
32namespace QuantExt {
33
34//! Index CDS option instrument
35class IndexCdsOption : public QuantLib::Option {
36public:
37 class arguments;
38 class results;
39 class engine;
40
41 IndexCdsOption(const QuantLib::ext::shared_ptr<IndexCreditDefaultSwap>& swap,
42 const QuantLib::ext::shared_ptr<QuantLib::Exercise>& exercise, QuantLib::Real strike,
44 Settlement::Type settlementType = Settlement::Cash,
45 QuantLib::Real tradeDateNtl = QuantLib::Null<QuantLib::Real>(),
46 QuantLib::Real realisedFep = QuantLib::Null<QuantLib::Real>(),
47 const QuantLib::Period& indexTerm = 5 * Years);
48
49 //! \name Instrument interface
50 //@{
51 bool isExpired() const override;
52 void setupArguments(QuantLib::PricingEngine::arguments* args) const override;
53 //@}
54
55 //! \name Inspectors
56 //@{
57 const QuantLib::ext::shared_ptr<IndexCreditDefaultSwap>& underlyingSwap() const { return swap_; }
58 //@}
59
60 //! \name Calculations
61 //@{
62 QuantLib::Rate atmRate() const;
63 QuantLib::Real riskyAnnuity() const;
64 QuantLib::Volatility
65 impliedVolatility(QuantLib::Real price,
66 const QuantLib::Handle<QuantLib::YieldTermStructure>& termStructureSwapCurrency,
67 const QuantLib::Handle<QuantLib::YieldTermStructure>& termStructureTradeCollateral,
68 const QuantLib::Handle<QuantLib::DefaultProbabilityTermStructure>&, QuantLib::Real recoveryRate,
69 QuantLib::Real accuracy = 1.e-4, QuantLib::Size maxEvaluations = 100,
70 QuantLib::Volatility minVol = 1.0e-7, QuantLib::Volatility maxVol = 4.0) const;
71 //@}
72
73private:
74 QuantLib::ext::shared_ptr<IndexCreditDefaultSwap> swap_;
75 QuantLib::Real strike_;
77 Settlement::Type settlementType_;
78 QuantLib::Real tradeDateNtl_;
79 QuantLib::Real realisedFep_;
80 QuantLib::Period indexTerm_;
81
82 mutable QuantLib::Real riskyAnnuity_;
83
84 //! \name Instrument interface
85 //@{
86 void setupExpired() const override;
87 void fetchResults(const QuantLib::PricingEngine::results* results) const override;
88 //@}
89};
90
91//! %Arguments for index CDS option calculation
92class IndexCdsOption::arguments : public IndexCreditDefaultSwap::arguments, public Option::arguments {
93public:
95 : strike(QuantLib::Null<QuantLib::Real>()), strikeType(CdsOption::Spread), settlementType(Settlement::Cash),
96 tradeDateNtl(QuantLib::Null<QuantLib::Real>()), realisedFep(QuantLib::Null<QuantLib::Real>()) {}
97
98 QuantLib::ext::shared_ptr<IndexCreditDefaultSwap> swap;
99 QuantLib::Real strike;
101 Settlement::Type settlementType;
102 QuantLib::Real tradeDateNtl;
103 QuantLib::Real realisedFep;
104 QuantLib::Period indexTerm;
105
106 void validate() const override;
107};
108
109//! %Results from index CDS option calculation
111public:
112 QuantLib::Real riskyAnnuity;
113
114 void reset() override;
115};
116
117//! Base class for index CDS option engines
118class IndexCdsOption::engine : public QuantLib::GenericEngine<IndexCdsOption::arguments, IndexCdsOption::results> {};
119
120}
121
122#endif
CDS option, removed requirements (rec must knock out, no upfront amount), that should be taken care o...
Arguments for index CDS option calculation
QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > swap
Base class for index CDS option engines.
Results from index CDS option calculation
Index CDS option instrument.
void setupArguments(QuantLib::PricingEngine::arguments *args) const override
QuantLib::Real riskyAnnuity() const
bool isExpired() const override
const QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > & underlyingSwap() const
QuantLib::Volatility impliedVolatility(QuantLib::Real price, const QuantLib::Handle< QuantLib::YieldTermStructure > &termStructureSwapCurrency, const QuantLib::Handle< QuantLib::YieldTermStructure > &termStructureTradeCollateral, const QuantLib::Handle< QuantLib::DefaultProbabilityTermStructure > &, QuantLib::Real recoveryRate, QuantLib::Real accuracy=1.e-4, QuantLib::Size maxEvaluations=100, QuantLib::Volatility minVol=1.0e-7, QuantLib::Volatility maxVol=4.0) const
void fetchResults(const QuantLib::PricingEngine::results *results) const override
CdsOption::StrikeType strikeType_
QuantLib::Rate atmRate() const
QuantLib::ext::shared_ptr< IndexCreditDefaultSwap > swap_
void setupExpired() const override
QuantLib::Real riskyAnnuity_
Settlement::Type settlementType_
QuantLib::Real tradeDateNtl_
QuantLib::Period indexTerm_
Index Credit default swap.