QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
syntheticcdo.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Roland Lichters
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
24#ifndef quantlib_synthetic_cdo_hpp
25#define quantlib_synthetic_cdo_hpp
26
27#include <ql/qldefines.hpp>
28
29#ifndef QL_PATCH_SOLARIS
30
31#include <ql/instrument.hpp>
32#include <ql/default.hpp>
33#include <ql/optional.hpp>
34#include <ql/time/schedule.hpp>
35
36#include <ql/experimental/credit/basket.hpp>
37#include <ql/cashflows/fixedratecoupon.hpp>
38
39namespace QuantLib {
40
41 class YieldTermStructure;
42
44
106 class SyntheticCDO : public Instrument {
107 public:
108 class arguments;
109 class results;
110 class engine;
111
112 // Review: No accrual settlement flag. No separate upfront payment date.
113 // Review: Forward start case.
120 SyntheticCDO (const ext::shared_ptr<Basket>& basket,
121 Protection::Side side,
122 const Schedule& schedule,
123 Rate upfrontRate,
124 Rate runningRate,
125 const DayCounter& dayCounter,
126 BusinessDayConvention paymentConvention,
127 ext::optional<Real> notional = ext::nullopt);
128
129 const ext::shared_ptr<Basket>& basket() const { return basket_; }
130
131 bool isExpired() const override;
132 Rate fairPremium() const;
133 Rate fairUpfrontPremium() const;
134 Rate premiumValue () const;
135 Rate protectionValue () const;
136 Real premiumLegNPV() const;
137 Real protectionLegNPV() const;
141 Real remainingNotional() const;
146 return leverageFactor_;
147 }
149 const Date& maturity() const {
150 return ext::dynamic_pointer_cast<FixedRateCoupon>(
151 normalizedLeg_.back())->accrualEndDate();
152 }
157 Real implicitCorrelation(const std::vector<Real>& recoveries,
158 const Handle<YieldTermStructure>& discountCurve,
159 Real targetNPV = 0.,
160 Real accuracy = 1.0e-3) const;
161
165 std::vector<Real> expectedTrancheLoss() const;
166 Size error () const;
167
168 void setupArguments(PricingEngine::arguments*) const override;
169 void fetchResults(const PricingEngine::results*) const override;
170
171 private:
172 void setupExpired() const override;
173
174 ext::shared_ptr<Basket> basket_;
177
183
188 mutable Size error_;
189 mutable std::vector<Real> expectedTrancheLoss_;
190 };
191
193 public:
194 arguments() : side(Protection::Side(-1)),
196 runningRate(Null<Real>()) {}
197 void validate() const override;
198
199 ext::shared_ptr<Basket> basket;
202
208 };
209
211 public:
212 void reset() override;
219 /* Expected tranche losses affecting this tranche coupons. Notice this
220 number might be below the actual basket losses, since the cdo protection
221 might start after basket inception (forward start CDO)*/
222 std::vector<Real> expectedTrancheLoss;
223 };
224
225
228 public GenericEngine<SyntheticCDO::arguments,
229 SyntheticCDO::results> { };
230
231}
232
233#endif
234
235#endif
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
template base class for option pricing engines
Shared handle to an observable.
Definition: handle.hpp:41
Abstract instrument class.
Definition: instrument.hpp:44
template class providing a null value for a given type.
Definition: null.hpp:76
Payment schedule.
Definition: schedule.hpp:40
ext::shared_ptr< Basket > basket
void validate() const override
BusinessDayConvention paymentConvention
std::vector< Real > expectedTrancheLoss
Synthetic Collateralized Debt Obligation.
Rate fairUpfrontPremium() const
ext::shared_ptr< Basket > basket_
void setupArguments(PricingEngine::arguments *) const override
const ext::shared_ptr< Basket > & basket() const
bool isExpired() const override
returns whether the instrument might have value greater than zero.
const Date & maturity() const
Last protection date.
Real implicitCorrelation(const std::vector< Real > &recoveries, const Handle< YieldTermStructure > &discountCurve, Real targetNPV=0., Real accuracy=1.0e-3) const
Rate protectionValue() const
Protection::Side side_
Real protectionLegNPV() const
BusinessDayConvention paymentConvention_
Real premiumLegNPV() const
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
std::vector< Real > expectedTrancheLoss() const
Rate premiumValue() const
Real leverageFactor() const
std::vector< Real > expectedTrancheLoss_
Real remainingNotional() const
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
const boost::none_t & nullopt
Definition: optional.cpp:27
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
information on a default-protection contract
Definition: default.hpp:32