QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
cvaswapengine.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2015 Jose Aparicio
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#ifndef quantlib_cva_swap_engine_hpp
21#define quantlib_cva_swap_engine_hpp
22
23#include <ql/handle.hpp>
26
27namespace QuantLib {
28
29 class YieldTermStructure;
30 class Quote;
31
32 /*! Bilateral (CVA and DVA) default adjusted vanilla swap pricing
33 engine. Collateral is not considered. No wrong way risk is
34 considered (rates and counterparty default are uncorrelated).
35 Based on:
36 Sorensen, E.H. and Bollier, T.F., Pricing swap default
37 risk. Financial Analysts Journal, 1994, 50, 23–33
38 Also see sect. II-5 in: Risk Neutral Pricing of Counterparty Risk
39 D. Brigo, M. Masetti, 2004
40 or in sections 3 and 4 of "A Formula for Interest Rate Swaps
41 Valuation under Counterparty Risk in presence of Netting Agreements"
42 D. Brigo and M. Masetti; May 4, 2005
43
44 to do: Compute fair rate through iteration instead of the
45 current approximation .
46 to do: write Issuer based constructors (event type)
47 to do: Check consistency between option engine discount and the one given
48 */
50 public:
51 //! \name Constructors
52 //@{
53 //!
54 /*! Creates the engine from an arbitrary swaption engine.
55 If the investor default model is not given a default
56 free one is assumed.
57 @param discountCurve Used in pricing.
58 @param swaptionEngine Determines the volatility and thus the
59 exposure model.
60 @param ctptyDTS Counterparty default curve.
61 @param ctptyRecoveryRate Counterparty recovey rate.
62 @param invstDTS Investor (swap holder) default curve.
63 @param invstRecoveryRate Investor recovery rate.
64 */
66 const Handle<YieldTermStructure>& discountCurve,
67 const Handle<PricingEngine>& swaptionEngine,
69 Real ctptyRecoveryRate,
72 Real invstRecoveryRate = 0.999);
73 /*! Creates an engine with a black volatility model for the
74 exposure.
75 If the investor default model is not given a default
76 free one is assumed.
77 @param discountCurve Used in pricing.
78 @param blackVol Black volatility used in the exposure model.
79 @param ctptyDTS Counterparty default curve.
80 @param ctptyRecoveryRate Counterparty recovey rate.
81 @param invstDTS Investor (swap holder) default curve.
82 @param invstRecoveryRate Investor recovery rate.
83 */
85 Volatility blackVol,
87 Real ctptyRecoveryRate,
90 Real invstRecoveryRate = 0.999);
91 /*! Creates an engine with a black volatility model for the
92 exposure. The volatility is given as a quote.
93 If the investor default model is not given a default
94 free one is assumed.
95 @param discountCurve Used in pricing.
96 @param blackVol Black volatility used in the exposure model.
97 @param ctptyDTS Counterparty default curve.
98 @param ctptyRecoveryRate Counterparty recovey rate.
99 @param invstDTS Investor (swap holder) default curve.
100 @param invstRecoveryRate Investor recovery rate.
101 */
103 const Handle<YieldTermStructure>& discountCurve,
104 const Handle<Quote>& blackVol,
106 Real ctptyRecoveryRate,
109 Real invstRecoveryRate = 0.999);
110 //@}
111 void calculate() const override;
112
113 private:
121 };
122
123}
124
125#endif
Handle< YieldTermStructure > discountCurve_
Handle< PricingEngine > swaptionletEngine_
Handle< DefaultProbabilityTermStructure > invstDTS_
Handle< PricingEngine > baseSwapEngine_
Handle< DefaultProbabilityTermStructure > defaultTS_
Shared handle to an observable.
Definition: handle.hpp:41
default-probability term structure
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Globally accessible relinkable pointer.
Definition: any.hpp:35
Simple fixed-rate vs Libor swap.